Mercyhurst University is a 4 years, Catholic institution founded in 1926 by the sisters of Mercy. It’s a liberal arts college in Erie, Pennsylvania. About 126 students from it responded on a survey about their food choices and preferences. Forming the dataset which is about the data taken from male and female students who answered several questions regarding their GPA, comfort food and the reason behind it. Their favorite food and their diet habit, the number of exercises they do per day, and how do their eating change along with their years in college from being freshman up till being seniors. Also the number of their meals intake are counted which is split into turkey, chicken, waffle, tortilla and scone. Their coffee and alcoholic intake are counted etc. and asking them about their family member’s education, profession and fav cuisine too.In addition to the students’ awareness of saving the environment through testing their understandings about carbon footprint.Carbon footprint is the greenhouse gas emissions produced by growing, rearing, farming, processing, transporting, storing, cooking and disposing of the food you eat.The main concern is to inform students that changing the foods that they eat can have a big impact on their carbon footprint, and reduce pollution, preserve the environment and slow global warming.
The dataset will help in identifying the following:
The dataset attributes that will be used are
GPA of each student in the college. Gender of each student. calories_chicken is the calories of the chicken the students eat per day. calories_scone is the calories of the scone the students eat per day. Coffee states whether the students drink coffee or not. drink states Whether the students drink alcohol or not. eating_changes describes how the eating habits got changed for the students. employment describes the number of employed students while studying in college. Income describes the status of the students’ social standards . Fav_Food describes each student favorite food. Pay_meal_out is the frequency in which students pay for meal out. tortilla_calories is the calories of tortilla that the students eat per day. waffle_calories is the calories of waffles that the students eat per day. weight of each student in lbs. weightIKG of each student after it got converted into kilograms. HEIGHT of each student in cm.. eating_Out The average of days for students eating out per week. Studying_hrsis students studying hours daily. Exercise is the number of exercises that the each student do per week. Vegan is the percentage of students willing for following vegan diet. CoffeAddict is the percentage of coffee addiction that each student has. caloriesSum is the sum of calories that each student eat per day. CaloriesReduction is the amount of calories remained for students after eating and doing exercises. CO2Kilos is the amount of carbon dioxide emitted in the environment. CarMiles are the kilometers that the car has been driven to reach a certain place. CarRemoval is the amount of cars that will be remove from the street Meditertanean_diet is the percentage of the students who are likely wanting to follow Meditertanean_diet
#Read Datasets
dataset <- read.csv("C:\\users\\pc\\Documents\\food_coded.csv", sep=",", header=TRUE)
dim(dataset)
## [1] 498 68
dataset2<-read.csv("C:\\users\\pc\\Documents\\StudyingDataset.csv", sep=",", header=TRUE)
dim(dataset2)
## [1] 498 4
dataset3<-read.csv("C:\\users\\pc\\Documents\\carbonFootprint.csv", sep=",", header=TRUE)
dim(dataset3)
## [1] 498 4
## the required packages to run the project
#install.packages("assertive")
#install.packages("ggpubr")
#install.packages(""plotly")
#install.packages("ggplot2")
#install.packages("ggcorrplot")
#intsall.packages("ggplotly")
#install.packages("dplyr")
#install.packages("ggpubr")
the code for loading the library
library(assertive)
library("ggpubr")
## Loading required package: ggplot2
library("plotly")
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(ggplot2)
library("ggcorrplot")
The following shows the greenhouse gas emissions produced by one kilo of each food. It includes all the emissions produced on the farm, in the factory, on the road, in the shop and in your home. It also shows how many miles the students need to drive to produce that many greenhouse gases
# Inserting certain numbers according to the carbon footprint table
dataset$fav_food[3]<-2
dataset$fav_food[4]<-5
dataset$fav_food[5]<-6
dataset$fav_food[10]<-7
dataset$fav_food[14]<-8
dataset$fav_food[20]<-9
dataset$fav_food[25]<-4
dataset$fav_food[30]<-10
dataset$fav_food[31]<-10
dataset$fav_food[50]<-11
dataset$fav_food[51]<-11
dataset$fav_food[52]<-12
dataset$fav_food[70]<-13
dataset$fav_food[73]<-14
dataset$fav_food[79]<-15
dataset$fav_food[80]<-16
dataset$fav_food<-as.integer(dataset$fav_food)
fav_food<-dataset$fav_food
fav_food
## [1] 1 1 2 5 6 3 1 1 3 7 1 1 3 8 3 2 1 3 3 9 3 2 1 1 4
## [26] 3 1 1 1 10 10 1 NA 1 3 1 3 1 1 1 1 1 1 3 1 1 1 3 1 11
## [51] 11 12 1 3 1 1 1 3 1 3 1 2 1 1 3 3 1 1 1 13 1 1 14 1 2
## [76] 1 3 2 15 16 3 1 1 1 3 3 3 2 1 1 1 3 1 1 1 3 3 1 NA 1
## [101] 1 3 3 1 3 3 1 3 2 2 1 1 3 1 3 3 2 3 1 3 1 1 1 3 1
## [126] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [151] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [176] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [201] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [226] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [251] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [276] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [301] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [326] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [351] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [376] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [401] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [426] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [451] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [476] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
dataset$CO2kilos<-c(0:497)
dataset$Co2Kilos
## [1] 39.2 39.2 13.5 39.2 13.5 13.5 39.2 39.2 13.5 39.2 39.2 39.2 13.5 39.2 13.5
## [16] 27.0 39.2 13.5 13.5 39.2 13.5 27.0 39.2 39.2 39.2 13.5 39.2 39.2 39.2 39.2
## [31] 27.0 39.2 NA 39.2 13.5 39.2 13.5 39.2 39.2 39.2 39.2 39.2 39.2 13.5 39.2
## [46] 39.2 39.2 13.5 39.2 39.2 27.0 39.2 39.2 13.5 39.2 39.2 39.2 13.5 39.2 13.5
## [61] 39.2 27.0 39.2 39.2 13.5 13.5 39.2 39.2 39.2 39.2 39.2 39.2 27.0 39.2 27.0
## [76] 39.2 13.5 27.0 39.2 39.2 13.5 39.2 39.2 39.2 13.5 13.5 13.5 27.0 39.2 39.2
## [91] 39.2 13.5 39.2 39.2 39.2 13.5 13.5 39.2 NA 39.2 39.2 13.5 13.5 39.2 13.5
## [106] 13.5 39.2 13.5 27.0 27.0 39.2 39.2 13.5 39.2 13.5 13.5 27.0 13.5 39.2 13.5
## [121] 39.2 39.2 39.2 13.5 39.2 NA NA NA NA NA NA NA NA NA NA
## [136] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [151] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [166] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [181] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [196] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [211] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [226] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [241] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [256] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [271] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [286] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [301] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [316] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [331] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [346] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [361] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [376] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [391] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [406] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [421] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [436] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [451] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [466] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [481] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [496] NA NA NA
for(i in 1:496){
if (is.na(dataset$fav_food[i])) {
print('Missing')
}
else if (dataset$fav_food[i]==1){
dataset$Co2Kilos[i]<-"39.2"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==2){
dataset$Co2Kilos[i]<-"27.0"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==3){
dataset$Co2Kilos[i]<-"13.5"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==4){
dataset$Co2Kilos[i]<-"12.1"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==5){
dataset$Co2Kilos[i]<-"10.9"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==6){
dataset$Co2Kilos[i]<-"6.9"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==7){
dataset$Co2Kilos[i]<-"6.1"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==8){
dataset$Co2Kilos[i]<-"4.8"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==9){
dataset$Co2Kilos[i]<-"2.9"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==10){
dataset$Co2Kilos[i]<-"2.7"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==11){
dataset$Co2Kilos[i]<-"2.3"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==12){
dataset$Co2Kilos[i]<-"2.0"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==13){
dataset$Co2Kilos[i]<-"2.0"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==14){
dataset$Co2Kilos[i]<-"1.9"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==15){
dataset$Co2Kilos[i]<-"1.1"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else if (dataset$fav_food[i]==16){
dataset$Co2Kilos[i]<-"0.9"
print(as.double(dataset$Co2Kilos[i]))
i<-+1
}
else
print('NA')
}
## [1] 39.2
## [1] 39.2
## [1] 27
## [1] 10.9
## [1] 6.9
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 6.1
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 4.8
## [1] 13.5
## [1] 27
## [1] 39.2
## [1] 13.5
## [1] 13.5
## [1] 2.9
## [1] 13.5
## [1] 27
## [1] 39.2
## [1] 39.2
## [1] 12.1
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 2.7
## [1] 2.7
## [1] 39.2
## [1] "Missing"
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 2.3
## [1] 2.3
## [1] 2
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 27
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 2
## [1] 39.2
## [1] 39.2
## [1] 1.9
## [1] 39.2
## [1] 27
## [1] 39.2
## [1] 13.5
## [1] 27
## [1] 1.1
## [1] 0.9
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 13.5
## [1] 13.5
## [1] 27
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 13.5
## [1] 39.2
## [1] "Missing"
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 13.5
## [1] 39.2
## [1] 13.5
## [1] 13.5
## [1] 39.2
## [1] 13.5
## [1] 27
## [1] 27
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 13.5
## [1] 13.5
## [1] 27
## [1] 13.5
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] 39.2
## [1] 39.2
## [1] 13.5
## [1] 39.2
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
CarMiles<-c(2:499)
dataset$CarMiles<-CarMiles
j<-1
for(j in j:497){
if (is.na(dataset$fav_food[i])&& is.na(dataset$Co2Kilos[j]) ) {
print('Missing')
}
else if ((dataset$fav_food[j]==1) && (dataset$Co2Kilos[j]==39.2)){
dataset$CarMiles<-"91"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==2) && (dataset$Co2Kilos[j]==27.0) ){
dataset$CarMiles<-"63"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==3 ) && (dataset$Co2Kilos[j]==13.5)){
dataset$CarMiles<-"31"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==4) && (dataset$Co2Kilos[j]==12.1)){
dataset$CarMiles<-"28"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==5) && (dataset$Co2Kilos[j]==10.9)){
dataset$CarMiles<-"25"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==6) && (dataset$Co2Kilos[j]==6.9) ){
dataset$CarMiles<-"16"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==7) && (dataset$Co2Kilos[j]==6.1)){
dataset$CarMiles<-"14"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==8) && (dataset$Co2Kilos[j]==4.8)){
dataset$CarMiles<-"11"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==9) && (dataset$Co2Kilos[j]==2.9)){
dataset$CarMiles<-"7"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==10) && (dataset$Co2Kilos[j]==2.7)){
dataset$CarMiles<-"6"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==11) && (dataset$Co2Kilos[j]==2.3)){
dataset$CarMiles<-"5"
print(as.double(dataset$CarMiles[j]))
j<j-+1
}
else if ((dataset$fav_food[j]==12) && (dataset$Co2Kilos[j]==2.0)){
dataset$CarMiles<-"4.5"
print(as.double(dataset$CarMiles[j]))
j<j-+1
}
else if ((dataset$fav_food[j]==13) && (dataset$Co2Kilos[j]==2.0)){
dataset$CarMiles<-"4.5"
print(as.double(dataset$CarMiles[j]))
j<j-+1
}
else if ((dataset$fav_food[j]==14) && (dataset$Co2Kilos[j]==1.9)){
dataset$CarMiles<-"4"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else if ((dataset$fav_food[j]==15) && (dataset$Co2Kilos[j]==1.1) ){
dataset$CarMiles<-"2.5"
print(as.double(dataset$CarMiles[i]))
j<-j+1
}
else if ((dataset$fav_food[j]==16) && (dataset$Co2Kilos[j]==0.9)){
dataset$CarMiles<-"2"
print(as.double(dataset$CarMiles[j]))
j<-j+1
}
else
print('NA')
}
## [1] 91
## [1] 91
## [1] "NA"
## [1] 25
## [1] 16
## [1] 31
## [1] 91
## [1] 91
## [1] 31
## [1] 14
## [1] 91
## [1] 91
## [1] 31
## [1] 11
## [1] 31
## [1] "NA"
## [1] 91
## [1] 31
## [1] 31
## [1] 7
## [1] 31
## [1] "NA"
## [1] 91
## [1] 91
## [1] 28
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] 6
## [1] 6
## [1] 91
## [1] "Missing"
## [1] 91
## [1] 31
## [1] 91
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] 91
## [1] 91
## [1] 91
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] 31
## [1] 91
## [1] 5
## [1] 5
## [1] "NA"
## [1] 91
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] 31
## [1] 91
## [1] 31
## [1] 91
## [1] "NA"
## [1] 91
## [1] 91
## [1] 31
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] "NA"
## [1] 91
## [1] 91
## [1] 4
## [1] 91
## [1] "NA"
## [1] 91
## [1] 31
## [1] "NA"
## [1] 2.5
## [1] 2
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] 31
## [1] 31
## [1] 31
## [1] "NA"
## [1] 91
## [1] 91
## [1] 91
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] 31
## [1] 31
## [1] 91
## [1] "Missing"
## [1] 91
## [1] 91
## [1] 31
## [1] 31
## [1] 91
## [1] 31
## [1] 31
## [1] 91
## [1] 31
## [1] "NA"
## [1] "NA"
## [1] 91
## [1] 91
## [1] 31
## [1] 91
## [1] 31
## [1] 31
## [1] "NA"
## [1] 31
## [1] 91
## [1] 31
## [1] 91
## [1] 91
## [1] 91
## [1] 31
## [1] 91
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
## [1] "Missing"
j<-1
#Assigning values for the students' height
H<-c(120:617)
H
## [1] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
## [19] 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
## [37] 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
## [55] 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
## [73] 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
## [91] 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
## [109] 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
## [127] 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
## [145] 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
## [163] 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
## [181] 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
## [199] 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
## [217] 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
## [235] 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
## [253] 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
## [271] 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
## [289] 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
## [307] 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
## [325] 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
## [343] 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
## [361] 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
## [379] 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
## [397] 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
## [415] 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
## [433] 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
## [451] 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
## [469] 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605
## [487] 606 607 608 609 610 611 612 613 614 615 616 617
dataset$height<-as.integer(H) #Cast type height from string into integer
dataset$height
## [1] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
## [19] 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
## [37] 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
## [55] 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
## [73] 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
## [91] 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
## [109] 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
## [127] 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
## [145] 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
## [163] 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
## [181] 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
## [199] 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
## [217] 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
## [235] 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
## [253] 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
## [271] 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
## [289] 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
## [307] 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
## [325] 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
## [343] 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
## [361] 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
## [379] 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
## [397] 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
## [415] 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
## [433] 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
## [451] 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
## [469] 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605
## [487] 606 607 608 609 610 611 612 613 614 615 616 617
#Function ConvertToKG that converts the weight unit from lbs to KG
covertToKG <- function(x) {
result<-x/2.2
result<-as.numeric(result)
resultKG<-as.numeric(result)
return (resultKG)
}
w<-dataset$weight
##Convert the weight into KG and double
dataset$weightINKG<-as.numeric(w)
## Warning: NAs introduced by coercion
dataset$weightINKG<-covertToKG(dataset$weightINKG)
dataset$weightINKG
## [1] 85.00000 70.45455 NA NA 86.36364 86.36364 81.81818
## [8] 62.27273 81.81818 56.81818 52.72727 50.00000 120.00000 55.90909
## [15] 84.09091 81.81818 65.90909 77.27273 61.36364 75.00000 79.54545
## [22] 88.63636 84.09091 84.09091 47.72727 56.81818 72.72727 79.54545
## [29] 81.81818 75.90909 52.27273 93.18182 NaN 58.18182 68.18182
## [36] 68.18182 68.18182 77.27273 68.18182 79.54545 63.63636 54.54545
## [43] 61.36364 45.45455 77.27273 51.36364 76.36364 65.90909 70.45455
## [50] 68.18182 76.81818 84.09091 90.90909 120.45455 75.00000 87.27273
## [57] 79.54545 63.63636 70.45455 70.45455 61.36364 53.63636 95.45455
## [64] 81.81818 63.63636 50.90909 56.81818 NA 65.90909 59.09091
## [71] 63.63636 63.63636 63.63636 90.90909 NaN 54.54545 68.18182
## [78] 90.90909 61.36364 65.90909 59.09091 86.36364 77.27273 57.72727
## [85] 75.90909 63.63636 86.36364 70.45455 79.54545 58.63636 118.18182
## [92] 61.36364 86.36364 75.00000 79.54545 83.63636 95.45455 70.45455
## [99] 84.09091 75.00000 56.81818 72.72727 61.36364 59.09091 104.54545
## [106] 56.81818 59.09091 75.00000 58.18182 90.90909 72.72727 77.27273
## [113] 58.63636 77.27273 62.72727 68.18182 77.27273 51.36364 63.63636
## [120] 84.09091 70.90909 81.81818 54.54545 61.36364 61.36364 NA
## [127] NA NA NA NA NA NA NA
## [134] NA NA NA NA NA NA NA
## [141] NA NA NA NA NA NA NA
## [148] NA NA NA NA NA NA NA
## [155] NA NA NA NA NA NA NA
## [162] NA NA NA NA NA NA NA
## [169] NA NA NA NA NA NA NA
## [176] NA NA NA NA NA NA NA
## [183] NA NA NA NA NA NA NA
## [190] NA NA NA NA NA NA NA
## [197] NA NA NA NA NA NA NA
## [204] NA NA NA NA NA NA NA
## [211] NA NA NA NA NA NA NA
## [218] NA NA NA NA NA NA NA
## [225] NA NA NA NA NA NA NA
## [232] NA NA NA NA NA NA NA
## [239] NA NA NA NA NA NA NA
## [246] NA NA NA NA NA NA NA
## [253] NA NA NA NA NA NA NA
## [260] NA NA NA NA NA NA NA
## [267] NA NA NA NA NA NA NA
## [274] NA NA NA NA NA NA NA
## [281] NA NA NA NA NA NA NA
## [288] NA NA NA NA NA NA NA
## [295] NA NA NA NA NA NA NA
## [302] NA NA NA NA NA NA NA
## [309] NA NA NA NA NA NA NA
## [316] NA NA NA NA NA NA NA
## [323] NA NA NA NA NA NA NA
## [330] NA NA NA NA NA NA NA
## [337] NA NA NA NA NA NA NA
## [344] NA NA NA NA NA NA NA
## [351] NA NA NA NA NA NA NA
## [358] NA NA NA NA NA NA NA
## [365] NA NA NA NA NA NA NA
## [372] NA NA NA NA NA NA NA
## [379] NA NA NA NA NA NA NA
## [386] NA NA NA NA NA NA NA
## [393] NA NA NA NA NA NA NA
## [400] NA NA NA NA NA NA NA
## [407] NA NA NA NA NA NA NA
## [414] NA NA NA NA NA NA NA
## [421] NA NA NA NA NA NA NA
## [428] NA NA NA NA NA NA NA
## [435] NA NA NA NA NA NA NA
## [442] NA NA NA NA NA NA NA
## [449] NA NA NA NA NA NA NA
## [456] NA NA NA NA NA NA NA
## [463] NA NA NA NA NA NA NA
## [470] NA NA NA NA NA NA NA
## [477] NA NA NA NA NA NA NA
## [484] NA NA NA NA NA NA NA
## [491] NA NA NA NA NA NA NA
## [498] NA
#data pre-processing
#Students height that is higher than 189 is replaced by 0, as there won't be a college student higher than that
dataset$HEIGHT<-replace( dataset$height,dataset$height>189 ,0)
dataset$HEIGHT
## [1] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
## [19] 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
## [37] 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
## [55] 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 0 0
## [73] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [91] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [109] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [127] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [145] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [163] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [181] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [199] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [217] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [235] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [253] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [271] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [289] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [307] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [325] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [343] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [361] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [379] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [397] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [415] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [433] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [451] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [469] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [487] 0 0 0 0 0 0 0 0 0 0 0 0
h<-dataset$HEIGHT
h<-as.integer(h)
h
## [1] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
## [19] 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
## [37] 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
## [55] 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 0 0
## [73] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [91] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [109] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [127] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [145] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [163] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [181] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [199] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [217] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [235] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [253] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [271] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [289] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [307] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [325] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [343] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [361] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [379] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [397] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [415] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [433] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [451] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [469] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [487] 0 0 0 0 0 0 0 0 0 0 0 0
#Replace all the values of CO2kilos that are greater than 39.2 with NA
dataset$Co2KilosS<-as.double(dataset$Co2Kilos)
dataset$Co2Kilos<-replace(dataset$Co2KilosS, dataset$Co2KilosS > 39.2, NA)
#Remove NA from CO2Kilos
K=na.omit(dataset$Co2Kilos)
K
## [1] 39.2 39.2 27.0 10.9 6.9 13.5 39.2 39.2 13.5 6.1 39.2 39.2 13.5 4.8 13.5
## [16] 27.0 39.2 13.5 13.5 2.9 13.5 27.0 39.2 39.2 12.1 13.5 39.2 39.2 39.2 2.7
## [31] 2.7 39.2 39.2 13.5 39.2 13.5 39.2 39.2 39.2 39.2 39.2 39.2 13.5 39.2 39.2
## [46] 39.2 13.5 39.2 2.3 2.3 2.0 39.2 13.5 39.2 39.2 39.2 13.5 39.2 13.5 39.2
## [61] 27.0 39.2 39.2 13.5 13.5 39.2 39.2 39.2 2.0 39.2 39.2 1.9 39.2 27.0 39.2
## [76] 13.5 27.0 1.1 0.9 13.5 39.2 39.2 39.2 13.5 13.5 13.5 27.0 39.2 39.2 39.2
## [91] 13.5 39.2 39.2 39.2 13.5 13.5 39.2 39.2 39.2 13.5 13.5 39.2 13.5 13.5 39.2
## [106] 13.5 27.0 27.0 39.2 39.2 13.5 39.2 13.5 13.5 27.0 13.5 39.2 13.5 39.2 39.2
## [121] 39.2 13.5 39.2
## attr(,"na.action")
## [1] 33 99 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
## [19] 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
## [37] 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
## [55] 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
## [73] 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
## [91] 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
## [109] 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
## [127] 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
## [145] 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
## [163] 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
## [181] 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
## [199] 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
## [217] 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
## [235] 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
## [253] 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
## [271] 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
## [289] 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
## [307] 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
## [325] 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
## [343] 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
## [361] 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
## attr(,"class")
## [1] "omit"
#Remove NA values from co2Kilos
dataset$Co2KilosS <-replace(dataset$Co2KilosS,is.na(dataset$Co2KilosS),na.omit(dataset$Co2Kilos))
## Warning in x[list] <- values: number of items to replace is not a multiple of
## replacement length
dataset$Co2KilosS
## [1] 39.2 39.2 27.0 10.9 6.9 13.5 39.2 39.2 13.5 6.1 39.2 39.2 13.5 4.8 13.5
## [16] 27.0 39.2 13.5 13.5 2.9 13.5 27.0 39.2 39.2 12.1 13.5 39.2 39.2 39.2 2.7
## [31] 2.7 39.2 39.2 39.2 13.5 39.2 13.5 39.2 39.2 39.2 39.2 39.2 39.2 13.5 39.2
## [46] 39.2 39.2 13.5 39.2 2.3 2.3 2.0 39.2 13.5 39.2 39.2 39.2 13.5 39.2 13.5
## [61] 39.2 27.0 39.2 39.2 13.5 13.5 39.2 39.2 39.2 2.0 39.2 39.2 1.9 39.2 27.0
## [76] 39.2 13.5 27.0 1.1 0.9 13.5 39.2 39.2 39.2 13.5 13.5 13.5 27.0 39.2 39.2
## [91] 39.2 13.5 39.2 39.2 39.2 13.5 13.5 39.2 39.2 39.2 39.2 13.5 13.5 39.2 13.5
## [106] 13.5 39.2 13.5 27.0 27.0 39.2 39.2 13.5 39.2 13.5 13.5 27.0 13.5 39.2 13.5
## [121] 39.2 39.2 39.2 13.5 39.2 27.0 10.9 6.9 13.5 39.2 39.2 13.5 6.1 39.2 39.2
## [136] 13.5 4.8 13.5 27.0 39.2 13.5 13.5 2.9 13.5 27.0 39.2 39.2 12.1 13.5 39.2
## [151] 39.2 39.2 2.7 2.7 39.2 39.2 13.5 39.2 13.5 39.2 39.2 39.2 39.2 39.2 39.2
## [166] 13.5 39.2 39.2 39.2 13.5 39.2 2.3 2.3 2.0 39.2 13.5 39.2 39.2 39.2 13.5
## [181] 39.2 13.5 39.2 27.0 39.2 39.2 13.5 13.5 39.2 39.2 39.2 2.0 39.2 39.2 1.9
## [196] 39.2 27.0 39.2 13.5 27.0 1.1 0.9 13.5 39.2 39.2 39.2 13.5 13.5 13.5 27.0
## [211] 39.2 39.2 39.2 13.5 39.2 39.2 39.2 13.5 13.5 39.2 39.2 39.2 13.5 13.5 39.2
## [226] 13.5 13.5 39.2 13.5 27.0 27.0 39.2 39.2 13.5 39.2 13.5 13.5 27.0 13.5 39.2
## [241] 13.5 39.2 39.2 39.2 13.5 39.2 39.2 39.2 27.0 10.9 6.9 13.5 39.2 39.2 13.5
## [256] 6.1 39.2 39.2 13.5 4.8 13.5 27.0 39.2 13.5 13.5 2.9 13.5 27.0 39.2 39.2
## [271] 12.1 13.5 39.2 39.2 39.2 2.7 2.7 39.2 39.2 13.5 39.2 13.5 39.2 39.2 39.2
## [286] 39.2 39.2 39.2 13.5 39.2 39.2 39.2 13.5 39.2 2.3 2.3 2.0 39.2 13.5 39.2
## [301] 39.2 39.2 13.5 39.2 13.5 39.2 27.0 39.2 39.2 13.5 13.5 39.2 39.2 39.2 2.0
## [316] 39.2 39.2 1.9 39.2 27.0 39.2 13.5 27.0 1.1 0.9 13.5 39.2 39.2 39.2 13.5
## [331] 13.5 13.5 27.0 39.2 39.2 39.2 13.5 39.2 39.2 39.2 13.5 13.5 39.2 39.2 39.2
## [346] 13.5 13.5 39.2 13.5 13.5 39.2 13.5 27.0 27.0 39.2 39.2 13.5 39.2 13.5 13.5
## [361] 27.0 13.5 39.2 13.5 39.2 39.2 39.2 13.5 39.2 39.2 39.2 27.0 10.9 6.9 13.5
## [376] 39.2 39.2 13.5 6.1 39.2 39.2 13.5 4.8 13.5 27.0 39.2 13.5 13.5 2.9 13.5
## [391] 27.0 39.2 39.2 12.1 13.5 39.2 39.2 39.2 2.7 2.7 39.2 39.2 13.5 39.2 13.5
## [406] 39.2 39.2 39.2 39.2 39.2 39.2 13.5 39.2 39.2 39.2 13.5 39.2 2.3 2.3 2.0
## [421] 39.2 13.5 39.2 39.2 39.2 13.5 39.2 13.5 39.2 27.0 39.2 39.2 13.5 13.5 39.2
## [436] 39.2 39.2 2.0 39.2 39.2 1.9 39.2 27.0 39.2 13.5 27.0 1.1 0.9 13.5 39.2
## [451] 39.2 39.2 13.5 13.5 13.5 27.0 39.2 39.2 39.2 13.5 39.2 39.2 39.2 13.5 13.5
## [466] 39.2 39.2 39.2 13.5 13.5 39.2 13.5 13.5 39.2 13.5 27.0 27.0 39.2 39.2 13.5
## [481] 39.2 13.5 13.5 27.0 13.5 39.2 13.5 39.2 39.2 39.2 13.5 39.2 39.2 39.2 27.0
## [496] 10.9 6.9 13.5
#Remove NA values from CarMiles
for(i in 1:length(dataset$CarMiles[i])){
dataset$CarMiles <-replace(dataset$CarMiles ,is.na(dataset$CarMiles), na.omit(dataset$CarMiles))
dataset$CarMiles
}
dataset$CarMiles
## [1] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [16] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [31] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [46] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [61] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [76] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [91] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [106] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [121] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [136] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [151] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [166] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [181] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [196] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [211] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [226] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [241] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [256] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [271] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [286] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [301] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [316] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [331] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [346] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [361] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [376] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [391] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [406] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [421] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [436] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [451] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [466] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [481] "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91" "91"
## [496] "91" "91" "91"
#Remove any NA data from fav food to get better results of the carbon footprint ranking
for ( i in 1:length(dataset$fav_food[i])){
dataset$fav_food<-replace( dataset$fav_food, is.na(dataset$fav_food),na.omit(dataset$fav_food))
dataset$fav_food
i<-+1
}
## Warning in x[list] <- values: number of items to replace is not a multiple of
## replacement length
dataset$fav_food
## [1] 1 1 2 5 6 3 1 1 3 7 1 1 3 8 3 2 1 3 3 9 3 2 1 1 4
## [26] 3 1 1 1 10 10 1 1 1 3 1 3 1 1 1 1 1 1 3 1 1 1 3 1 11
## [51] 11 12 1 3 1 1 1 3 1 3 1 2 1 1 3 3 1 1 1 13 1 1 14 1 2
## [76] 1 3 2 15 16 3 1 1 1 3 3 3 2 1 1 1 3 1 1 1 3 3 1 1 1
## [101] 1 3 3 1 3 3 1 3 2 2 1 1 3 1 3 3 2 3 1 3 1 1 1 3 1
## [126] 2 5 6 3 1 1 3 7 1 1 3 8 3 2 1 3 3 9 3 2 1 1 4 3 1
## [151] 1 1 10 10 1 1 3 1 3 1 1 1 1 1 1 3 1 1 1 3 1 11 11 12 1
## [176] 3 1 1 1 3 1 3 1 2 1 1 3 3 1 1 1 13 1 1 14 1 2 1 3 2
## [201] 15 16 3 1 1 1 3 3 3 2 1 1 1 3 1 1 1 3 3 1 1 1 3 3 1
## [226] 3 3 1 3 2 2 1 1 3 1 3 3 2 3 1 3 1 1 1 3 1 1 1 2 5
## [251] 6 3 1 1 3 7 1 1 3 8 3 2 1 3 3 9 3 2 1 1 4 3 1 1 1
## [276] 10 10 1 1 3 1 3 1 1 1 1 1 1 3 1 1 1 3 1 11 11 12 1 3 1
## [301] 1 1 3 1 3 1 2 1 1 3 3 1 1 1 13 1 1 14 1 2 1 3 2 15 16
## [326] 3 1 1 1 3 3 3 2 1 1 1 3 1 1 1 3 3 1 1 1 3 3 1 3 3
## [351] 1 3 2 2 1 1 3 1 3 3 2 3 1 3 1 1 1 3 1 1 1 2 5 6 3
## [376] 1 1 3 7 1 1 3 8 3 2 1 3 3 9 3 2 1 1 4 3 1 1 1 10 10
## [401] 1 1 3 1 3 1 1 1 1 1 1 3 1 1 1 3 1 11 11 12 1 3 1 1 1
## [426] 3 1 3 1 2 1 1 3 3 1 1 1 13 1 1 14 1 2 1 3 2 15 16 3 1
## [451] 1 1 3 3 3 2 1 1 1 3 1 1 1 3 3 1 1 1 3 3 1 3 3 1 3
## [476] 2 2 1 1 3 1 3 3 2 3 1 3 1 1 1 3 1 1 1 2 5 6 3
#Replace any unemployed student with 0 instead of NO DATA for better visualization
dataset$employment<-replace(dataset$employment, is.na(dataset$employment),0)
dataset$employment
## [1] 3 2 3 3 2 3 3 2 2 3 1 2 3 2 3 3 2 3 2 3 2 2 2 2 3 3 2 3 2 3 2 3 2 3 3 3 2
## [38] 2 3 3 3 2 2 0 2 2 2 0 3 0 3 3 0 0 3 3 3 2 2 3 3 2 2 3 2 3 3 2 3 3 2 2 2 3
## [75] 3 2 2 2 2 3 2 3 3 0 3 2 3 2 2 2 3 2 2 3 0 3 2 2 3 2 2 2 3 2 2 0 0 2 3 2 3
## [112] 2 3 2 3 2 3 2 2 2 1 3 3 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [186] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [223] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [260] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [297] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [334] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [371] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [408] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [445] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [482] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#Remove NA values from employment
dataset$employment2<-replace(dataset$employment, is.na(dataset$employment) ,na.omit(dataset$employment))
dataset$employment2<-as.numeric(dataset$employment2)
dataset$employment2
## [1] 3 2 3 3 2 3 3 2 2 3 1 2 3 2 3 3 2 3 2 3 2 2 2 2 3 3 2 3 2 3 2 3 2 3 3 3 2
## [38] 2 3 3 3 2 2 0 2 2 2 0 3 0 3 3 0 0 3 3 3 2 2 3 3 2 2 3 2 3 3 2 3 3 2 2 2 3
## [75] 3 2 2 2 2 3 2 3 3 0 3 2 3 2 2 2 3 2 2 3 0 3 2 2 3 2 2 2 3 2 2 0 0 2 3 2 3
## [112] 2 3 2 3 2 3 2 2 2 1 3 3 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [186] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [223] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [260] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [297] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [334] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [371] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [408] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [445] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [482] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#Replace any student with NO DATA about drinking alcohol or not with 0 for better visualization
dataset$drink<-replace(dataset$drink, is.na(dataset$drink),0)
dataset$drink
## [1] 1 2 1 2 2 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 2 0 1 1 2 1 1 2 1 2 1 2 2 1 1 1 2
## [38] 2 1 2 2 1 2 1 1 1 2 1 2 1 1 1 1 2 1 2 1 1 2 2 2 1 1 0 1 1 2 2 2 2 1 1 2 2
## [75] 2 1 2 2 1 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 1 2 2 1 2 2 1 1 2 2 1
## [112] 2 1 2 2 2 1 1 1 1 2 1 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [186] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [223] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [260] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [297] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [334] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [371] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [408] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [445] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [482] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#Categorizing the students' favorite food according to the carbon footprint table
dataset$fav_food=factor(dataset$fav_food,levels =c( "1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"),
labels=c("Lamb","Beef","Cheese","Pork","Turkey","Chicken","Tuna","Eggs","Potatoes","Rice","Nuts","Beans/tofu","Vegetables","Milk","Fruit","Lentil"))
dataset$fav_food
## [1] Lamb Lamb Beef Turkey Chicken Cheese
## [7] Lamb Lamb Cheese Tuna Lamb Lamb
## [13] Cheese Eggs Cheese Beef Lamb Cheese
## [19] Cheese Potatoes Cheese Beef Lamb Lamb
## [25] Pork Cheese Lamb Lamb Lamb Rice
## [31] Rice Lamb Lamb Lamb Cheese Lamb
## [37] Cheese Lamb Lamb Lamb Lamb Lamb
## [43] Lamb Cheese Lamb Lamb Lamb Cheese
## [49] Lamb Nuts Nuts Beans/tofu Lamb Cheese
## [55] Lamb Lamb Lamb Cheese Lamb Cheese
## [61] Lamb Beef Lamb Lamb Cheese Cheese
## [67] Lamb Lamb Lamb Vegetables Lamb Lamb
## [73] Milk Lamb Beef Lamb Cheese Beef
## [79] Fruit Lentil Cheese Lamb Lamb Lamb
## [85] Cheese Cheese Cheese Beef Lamb Lamb
## [91] Lamb Cheese Lamb Lamb Lamb Cheese
## [97] Cheese Lamb Lamb Lamb Lamb Cheese
## [103] Cheese Lamb Cheese Cheese Lamb Cheese
## [109] Beef Beef Lamb Lamb Cheese Lamb
## [115] Cheese Cheese Beef Cheese Lamb Cheese
## [121] Lamb Lamb Lamb Cheese Lamb Beef
## [127] Turkey Chicken Cheese Lamb Lamb Cheese
## [133] Tuna Lamb Lamb Cheese Eggs Cheese
## [139] Beef Lamb Cheese Cheese Potatoes Cheese
## [145] Beef Lamb Lamb Pork Cheese Lamb
## [151] Lamb Lamb Rice Rice Lamb Lamb
## [157] Cheese Lamb Cheese Lamb Lamb Lamb
## [163] Lamb Lamb Lamb Cheese Lamb Lamb
## [169] Lamb Cheese Lamb Nuts Nuts Beans/tofu
## [175] Lamb Cheese Lamb Lamb Lamb Cheese
## [181] Lamb Cheese Lamb Beef Lamb Lamb
## [187] Cheese Cheese Lamb Lamb Lamb Vegetables
## [193] Lamb Lamb Milk Lamb Beef Lamb
## [199] Cheese Beef Fruit Lentil Cheese Lamb
## [205] Lamb Lamb Cheese Cheese Cheese Beef
## [211] Lamb Lamb Lamb Cheese Lamb Lamb
## [217] Lamb Cheese Cheese Lamb Lamb Lamb
## [223] Cheese Cheese Lamb Cheese Cheese Lamb
## [229] Cheese Beef Beef Lamb Lamb Cheese
## [235] Lamb Cheese Cheese Beef Cheese Lamb
## [241] Cheese Lamb Lamb Lamb Cheese Lamb
## [247] Lamb Lamb Beef Turkey Chicken Cheese
## [253] Lamb Lamb Cheese Tuna Lamb Lamb
## [259] Cheese Eggs Cheese Beef Lamb Cheese
## [265] Cheese Potatoes Cheese Beef Lamb Lamb
## [271] Pork Cheese Lamb Lamb Lamb Rice
## [277] Rice Lamb Lamb Cheese Lamb Cheese
## [283] Lamb Lamb Lamb Lamb Lamb Lamb
## [289] Cheese Lamb Lamb Lamb Cheese Lamb
## [295] Nuts Nuts Beans/tofu Lamb Cheese Lamb
## [301] Lamb Lamb Cheese Lamb Cheese Lamb
## [307] Beef Lamb Lamb Cheese Cheese Lamb
## [313] Lamb Lamb Vegetables Lamb Lamb Milk
## [319] Lamb Beef Lamb Cheese Beef Fruit
## [325] Lentil Cheese Lamb Lamb Lamb Cheese
## [331] Cheese Cheese Beef Lamb Lamb Lamb
## [337] Cheese Lamb Lamb Lamb Cheese Cheese
## [343] Lamb Lamb Lamb Cheese Cheese Lamb
## [349] Cheese Cheese Lamb Cheese Beef Beef
## [355] Lamb Lamb Cheese Lamb Cheese Cheese
## [361] Beef Cheese Lamb Cheese Lamb Lamb
## [367] Lamb Cheese Lamb Lamb Lamb Beef
## [373] Turkey Chicken Cheese Lamb Lamb Cheese
## [379] Tuna Lamb Lamb Cheese Eggs Cheese
## [385] Beef Lamb Cheese Cheese Potatoes Cheese
## [391] Beef Lamb Lamb Pork Cheese Lamb
## [397] Lamb Lamb Rice Rice Lamb Lamb
## [403] Cheese Lamb Cheese Lamb Lamb Lamb
## [409] Lamb Lamb Lamb Cheese Lamb Lamb
## [415] Lamb Cheese Lamb Nuts Nuts Beans/tofu
## [421] Lamb Cheese Lamb Lamb Lamb Cheese
## [427] Lamb Cheese Lamb Beef Lamb Lamb
## [433] Cheese Cheese Lamb Lamb Lamb Vegetables
## [439] Lamb Lamb Milk Lamb Beef Lamb
## [445] Cheese Beef Fruit Lentil Cheese Lamb
## [451] Lamb Lamb Cheese Cheese Cheese Beef
## [457] Lamb Lamb Lamb Cheese Lamb Lamb
## [463] Lamb Cheese Cheese Lamb Lamb Lamb
## [469] Cheese Cheese Lamb Cheese Cheese Lamb
## [475] Cheese Beef Beef Lamb Lamb Cheese
## [481] Lamb Cheese Cheese Beef Cheese Lamb
## [487] Cheese Lamb Lamb Lamb Cheese Lamb
## [493] Lamb Lamb Beef Turkey Chicken Cheese
## 16 Levels: Lamb Beef Cheese Pork Turkey Chicken Tuna Eggs Potatoes ... Lentil
#Categorize students who take vitamins or not with yes or no
dataset$vitamins=factor(dataset$vitamins, levels = c( "1","2"), labels=c("Yes","NO"))
dataset$vitamins
## [1] Yes NO Yes Yes NO NO Yes NO NO Yes NO Yes NO NO Yes
## [16] NO Yes NO Yes NO NO NO Yes Yes NO NO NO Yes Yes Yes
## [31] Yes Yes Yes Yes Yes NO NO NO NO NO NO Yes NO Yes Yes
## [46] NO NO NO Yes NO NO Yes NO Yes Yes NO Yes Yes Yes NO
## [61] Yes Yes Yes NO Yes NO Yes NO NO Yes Yes Yes Yes Yes NO
## [76] Yes NO NO Yes NO Yes NO NO NO Yes Yes Yes Yes Yes Yes
## [91] Yes NO NO NO Yes NO Yes NO Yes Yes NO NO Yes Yes Yes
## [106] NO NO NO NO Yes NO NO NO NO NO NO Yes Yes NO NO
## [121] Yes NO NO Yes NO <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [136] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [151] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [166] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [181] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [196] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [211] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [226] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [241] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [256] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [271] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [286] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [301] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [316] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [331] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [346] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [361] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [376] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [391] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [406] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [421] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [436] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [451] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [466] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [481] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## [496] <NA> <NA> <NA>
## Levels: Yes NO
#Filtering any NA value from students' GPA
i<-1
for(i in i:length(dataset$Gender)){
dataset$Gender<-replace( dataset$Gender,is.na(dataset$Gender),na.omit(dataset$Gender))
dataset$Gender
i<-i+1
}
## Warning in x[list] <- values: number of items to replace is not a multiple of
## replacement length
dataset$GPAA
## NULL
#Categorize students' gender with Male and Female
dataset$Gender=factor(dataset$Gender, levels = c( "1","2"), labels=c("F","M"))
dataset$Gender
## [1] M F F F F F M F F F F F M F M M F M F M M M M M F F M M M M F M M F F F F
## [38] F F M M F F F F F M M M M M M M M M F M F F F F F M F F F F F F F F F M M
## [75] M F F M F M F F F F F F F M M F M F M M M M M F M F F F F F F F F F F F F
## [112] M F F M M F F F M F F F M F M F F F F F M F F F F F M F M M F M F M M M M
## [149] M F F M M M M F M M F F F F F F M M F F F F F M M M M M M M M M F M F F F
## [186] F F M F F F F F F F F F M M M F F M F M F F F F F F F M M F M F M M M M M
## [223] F M F F F F F F F F F F F F M F F M M F F F M F F F M F M F F F F F M F F
## [260] F F F M F M M F M F M M M M M F F M M M M F M M F F F F F F M M F F F F F
## [297] M M M M M M M M M F M F F F F F M F F F F F F F F F M M M F F M F M F F F
## [334] F F F F M M F M F M M M M M F M F F F F F F F F F F F F M F F M M F F F M
## [371] F F F M F M F F F F F M F F F F F M F M M F M F M M M M M F F M M M M F M
## [408] M F F F F F F M M F F F F F M M M M M M M M M F M F F F F F M F F F F F F
## [445] F F F M M M F F M F M F F F F F F F M M F M F M M M M M F M F F F F F F F
## [482] F F F F F M F F M M F F F M F F F
## Levels: F M
#Categorize students who drink alcohol or not with yes or no
dataset$drink=factor(dataset$drink, levels = c( "0","1","2"), labels=c("Undeclared","Yes","NO"))
dataset$drink
## [1] Yes NO Yes NO NO NO
## [7] Yes NO Yes Yes NO Yes
## [13] NO NO NO NO Yes NO
## [19] Yes NO NO Undeclared Yes Yes
## [25] NO Yes Yes NO Yes NO
## [31] Yes NO NO Yes Yes Yes
## [37] NO NO Yes NO NO Yes
## [43] NO Yes Yes Yes NO Yes
## [49] NO Yes Yes Yes Yes NO
## [55] Yes NO Yes Yes NO NO
## [61] NO Yes Yes Undeclared Yes Yes
## [67] NO NO NO NO Yes Yes
## [73] NO NO NO Yes NO NO
## [79] Yes NO NO NO NO Yes
## [85] NO NO NO NO NO Yes
## [91] NO NO NO NO NO NO
## [97] NO NO NO Yes Yes NO
## [103] NO Yes NO NO Yes Yes
## [109] NO NO Yes NO Yes NO
## [115] NO NO Yes Yes Yes Yes
## [121] NO Yes Yes NO Yes Undeclared
## [127] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [133] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [139] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [145] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [151] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [157] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [163] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [169] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [175] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [181] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [187] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [193] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [199] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [205] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [211] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [217] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [223] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [229] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [235] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [241] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [247] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [253] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [259] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [265] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [271] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [277] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [283] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [289] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [295] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [301] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [307] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [313] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [319] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [325] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [331] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [337] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [343] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [349] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [355] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [361] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [367] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [373] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [379] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [385] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [391] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [397] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [403] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [409] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [415] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [421] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [427] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [433] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [439] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [445] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [451] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [457] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [463] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [469] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [475] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [481] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [487] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## [493] Undeclared Undeclared Undeclared Undeclared Undeclared Undeclared
## Levels: Undeclared Yes NO
#Convert the string data into double for the GPA calculations
dataset$GPAA<-as.double(dataset$GPA)
## Warning: NAs introduced by coercion
dataset$GPAA
## [1] 2.400 3.654 3.300 3.200 3.500 2.250 3.800 3.300 3.300 3.300 3.500 3.904
## [13] 3.400 3.600 3.100 NaN 4.000 3.600 3.400 2.200 3.300 3.870 3.700 3.700
## [25] 3.900 2.800 3.700 3.000 3.200 3.500 4.000 4.000 3.400 2.800 3.650 3.000
## [37] 3.700 3.400 3.890 3.000 3.400 2.900 3.600 3.500 3.200 3.605 3.800 2.800
## [49] 3.500 3.830 3.600 3.300 3.300 3.292 3.500 3.350 3.800 2.800 3.500 3.700
## [61] 3.600 NA 3.900 2.600 3.500 3.200 3.000 3.600 3.200 3.670 3.730 4.000
## [73] 3.100 NA 2.710 3.000 3.700 3.100 3.000 3.900 3.400 3.500 3.700 3.700
## [85] 3.830 2.600 3.000 3.200 3.500 3.200 3.680 3.800 3.300 3.200 3.750 3.500
## [97] 3.920 3.900 3.900 3.200 3.500 3.400 NaN 3.700 NA 3.000 3.000 3.800
## [109] 3.800 3.400 3.700 2.900 3.900 3.600 2.800 3.300 3.400 3.770 3.630 3.200
## [121] 3.500 3.000 3.882 3.000 3.900 NA NA NA NA NA NA NA
## [133] NA NA NA NA NA NA NA NA NA NA NA NA
## [145] NA NA NA NA NA NA NA NA NA NA NA NA
## [157] NA NA NA NA NA NA NA NA NA NA NA NA
## [169] NA NA NA NA NA NA NA NA NA NA NA NA
## [181] NA NA NA NA NA NA NA NA NA NA NA NA
## [193] NA NA NA NA NA NA NA NA NA NA NA NA
## [205] NA NA NA NA NA NA NA NA NA NA NA NA
## [217] NA NA NA NA NA NA NA NA NA NA NA NA
## [229] NA NA NA NA NA NA NA NA NA NA NA NA
## [241] NA NA NA NA NA NA NA NA NA NA NA NA
## [253] NA NA NA NA NA NA NA NA NA NA NA NA
## [265] NA NA NA NA NA NA NA NA NA NA NA NA
## [277] NA NA NA NA NA NA NA NA NA NA NA NA
## [289] NA NA NA NA NA NA NA NA NA NA NA NA
## [301] NA NA NA NA NA NA NA NA NA NA NA NA
## [313] NA NA NA NA NA NA NA NA NA NA NA NA
## [325] NA NA NA NA NA NA NA NA NA NA NA NA
## [337] NA NA NA NA NA NA NA NA NA NA NA NA
## [349] NA NA NA NA NA NA NA NA NA NA NA NA
## [361] NA NA NA NA NA NA NA NA NA NA NA NA
## [373] NA NA NA NA NA NA NA NA NA NA NA NA
## [385] NA NA NA NA NA NA NA NA NA NA NA NA
## [397] NA NA NA NA NA NA NA NA NA NA NA NA
## [409] NA NA NA NA NA NA NA NA NA NA NA NA
## [421] NA NA NA NA NA NA NA NA NA NA NA NA
## [433] NA NA NA NA NA NA NA NA NA NA NA NA
## [445] NA NA NA NA NA NA NA NA NA NA NA NA
## [457] NA NA NA NA NA NA NA NA NA NA NA NA
## [469] NA NA NA NA NA NA NA NA NA NA NA NA
## [481] NA NA NA NA NA NA NA NA NA NA NA NA
## [493] NA NA NA NA NA NA
#Filtering any NA value from students' GPA
for(i in i:length(dataset$GPAA[i])){
dataset$GPAA<-replace( dataset$GPAA,is.na(dataset$GPAA),na.omit(dataset$GPAA))
dataset$GPAA
i<-i+1
}
## Warning in x[list] <- values: number of items to replace is not a multiple of
## replacement length
dataset$GPAA
## [1] 2.400 3.654 3.300 3.200 3.500 2.250 3.800 3.300 3.300 3.300 3.500 3.904
## [13] 3.400 3.600 3.100 2.400 4.000 3.600 3.400 2.200 3.300 3.870 3.700 3.700
## [25] 3.900 2.800 3.700 3.000 3.200 3.500 4.000 4.000 3.400 2.800 3.650 3.000
## [37] 3.700 3.400 3.890 3.000 3.400 2.900 3.600 3.500 3.200 3.605 3.800 2.800
## [49] 3.500 3.830 3.600 3.300 3.300 3.292 3.500 3.350 3.800 2.800 3.500 3.700
## [61] 3.600 3.654 3.900 2.600 3.500 3.200 3.000 3.600 3.200 3.670 3.730 4.000
## [73] 3.100 3.300 2.710 3.000 3.700 3.100 3.000 3.900 3.400 3.500 3.700 3.700
## [85] 3.830 2.600 3.000 3.200 3.500 3.200 3.680 3.800 3.300 3.200 3.750 3.500
## [97] 3.920 3.900 3.900 3.200 3.500 3.400 3.200 3.700 3.500 3.000 3.000 3.800
## [109] 3.800 3.400 3.700 2.900 3.900 3.600 2.800 3.300 3.400 3.770 3.630 3.200
## [121] 3.500 3.000 3.882 3.000 3.900 2.250 3.800 3.300 3.300 3.300 3.500 3.904
## [133] 3.400 3.600 3.100 4.000 3.600 3.400 2.200 3.300 3.870 3.700 3.700 3.900
## [145] 2.800 3.700 3.000 3.200 3.500 4.000 4.000 3.400 2.800 3.650 3.000 3.700
## [157] 3.400 3.890 3.000 3.400 2.900 3.600 3.500 3.200 3.605 3.800 2.800 3.500
## [169] 3.830 3.600 3.300 3.300 3.292 3.500 3.350 3.800 2.800 3.500 3.700 3.600
## [181] 3.900 2.600 3.500 3.200 3.000 3.600 3.200 3.670 3.730 4.000 3.100 2.710
## [193] 3.000 3.700 3.100 3.000 3.900 3.400 3.500 3.700 3.700 3.830 2.600 3.000
## [205] 3.200 3.500 3.200 3.680 3.800 3.300 3.200 3.750 3.500 3.920 3.900 3.900
## [217] 3.200 3.500 3.400 3.700 3.000 3.000 3.800 3.800 3.400 3.700 2.900 3.900
## [229] 3.600 2.800 3.300 3.400 3.770 3.630 3.200 3.500 3.000 3.882 3.000 3.900
## [241] 2.400 3.654 3.300 3.200 3.500 2.250 3.800 3.300 3.300 3.300 3.500 3.904
## [253] 3.400 3.600 3.100 4.000 3.600 3.400 2.200 3.300 3.870 3.700 3.700 3.900
## [265] 2.800 3.700 3.000 3.200 3.500 4.000 4.000 3.400 2.800 3.650 3.000 3.700
## [277] 3.400 3.890 3.000 3.400 2.900 3.600 3.500 3.200 3.605 3.800 2.800 3.500
## [289] 3.830 3.600 3.300 3.300 3.292 3.500 3.350 3.800 2.800 3.500 3.700 3.600
## [301] 3.900 2.600 3.500 3.200 3.000 3.600 3.200 3.670 3.730 4.000 3.100 2.710
## [313] 3.000 3.700 3.100 3.000 3.900 3.400 3.500 3.700 3.700 3.830 2.600 3.000
## [325] 3.200 3.500 3.200 3.680 3.800 3.300 3.200 3.750 3.500 3.920 3.900 3.900
## [337] 3.200 3.500 3.400 3.700 3.000 3.000 3.800 3.800 3.400 3.700 2.900 3.900
## [349] 3.600 2.800 3.300 3.400 3.770 3.630 3.200 3.500 3.000 3.882 3.000 3.900
## [361] 2.400 3.654 3.300 3.200 3.500 2.250 3.800 3.300 3.300 3.300 3.500 3.904
## [373] 3.400 3.600 3.100 4.000 3.600 3.400 2.200 3.300 3.870 3.700 3.700 3.900
## [385] 2.800 3.700 3.000 3.200 3.500 4.000 4.000 3.400 2.800 3.650 3.000 3.700
## [397] 3.400 3.890 3.000 3.400 2.900 3.600 3.500 3.200 3.605 3.800 2.800 3.500
## [409] 3.830 3.600 3.300 3.300 3.292 3.500 3.350 3.800 2.800 3.500 3.700 3.600
## [421] 3.900 2.600 3.500 3.200 3.000 3.600 3.200 3.670 3.730 4.000 3.100 2.710
## [433] 3.000 3.700 3.100 3.000 3.900 3.400 3.500 3.700 3.700 3.830 2.600 3.000
## [445] 3.200 3.500 3.200 3.680 3.800 3.300 3.200 3.750 3.500 3.920 3.900 3.900
## [457] 3.200 3.500 3.400 3.700 3.000 3.000 3.800 3.800 3.400 3.700 2.900 3.900
## [469] 3.600 2.800 3.300 3.400 3.770 3.630 3.200 3.500 3.000 3.882 3.000 3.900
## [481] 2.400 3.654 3.300 3.200 3.500 2.250 3.800 3.300 3.300 3.300 3.500 3.904
## [493] 3.400 3.600 3.100 4.000 3.600 3.400
#Assume that students who did not answer on diet changes that they did not change their diet
#replace any NA with 4 that has the no changes category
dataset$eating_changes
## [1] "eat faster" "eat out more" "eat faster"
## [4] "cheaper food" "no changes" "eat out more"
## [7] "eat healthier" "eat healthier" "eat healthier"
## [10] "eat out more" "no changes" "eat less"
## [13] "eat healthier" "less healthier" "eat healthier"
## [16] "no changes" "More Water" "eat healthier"
## [19] "eat out more" "no changes" "eat more"
## [22] "eat less" "eat out more" "eat less"
## [25] "eat more" "no changes" "eat out more"
## [28] "eat healthier" "eat healthier" "eat healthier"
## [31] "eat healthier" "no changes" "eat out more"
## [34] "eat out more" "eat less" "eat less"
## [37] "eat less" "eat out more" "eat more"
## [40] "eat more" "no changes" "eat out more"
## [43] "eat out more" "eat healthier" " no changes"
## [46] "eat less" "eat out more" "eat less"
## [49] "eat out more" "eat less healthier" "eat healthier"
## [52] "Mediocre " "eat less" "no changes"
## [55] "eat healthier" "eat on time" "eat healthier"
## [58] "eat faster " "eat more" "eat more"
## [61] "eat more" "eat healthier" "eat healthier"
## [64] NA "eat out more" "eat out more"
## [67] "eat more out" "eat out more" "eat out more"
## [70] "eat healthier" "eat less" "eat out more"
## [73] "eat out more" "More Water " NA
## [76] "eat less healthier" "eat less healthier" "eat more"
## [79] "eat less" "more coffee" "less healthier"
## [82] "no changes" "less healthier" "eat more "
## [85] "eat healthier" "eat more" "eat less"
## [88] "less healthier" "eat healthier" "eat healthier"
## [91] "eat healthier" "eat out more" "eat healthier"
## [94] "eat more" "eat more" "eat more"
## [97] "eat healthier" "eat healthier" "less healthier"
## [100] "eat healthier" "eat healthier" "eat more"
## [103] "eat healthier" "eat more" "eat more"
## [106] "eat less" "More Water " "eat more"
## [109] "eat more" "eat healthier" "eat out more"
## [112] "eat healthier" "eat healthier" "eat out more"
## [115] "unstable" "eat more" "less healthier"
## [118] "eat healthier" "eat healthier" "eat healthier"
## [121] "eat out more" "eat out more" "eat less"
## [124] "eat less" "eat healthier" ""
## [127] "" "" ""
## [130] "" "" ""
## [133] "" "" ""
## [136] "" "" ""
## [139] "" "" ""
## [142] "" "" ""
## [145] "" "" ""
## [148] "" "" ""
## [151] "" "" ""
## [154] "" "" ""
## [157] "" "" ""
## [160] "" "" ""
## [163] "" "" ""
## [166] "" "" ""
## [169] "" "" ""
## [172] "" "" ""
## [175] "" "" ""
## [178] "" "" ""
## [181] "" "" ""
## [184] "" "" ""
## [187] "" "" ""
## [190] "" "" ""
## [193] "" "" ""
## [196] "" "" ""
## [199] "" "" ""
## [202] "" "" ""
## [205] "" "" ""
## [208] "" "" ""
## [211] "" "" ""
## [214] "" "" ""
## [217] "" "" ""
## [220] "" "" ""
## [223] "" "" ""
## [226] "" "" ""
## [229] "" "" ""
## [232] "" "" ""
## [235] "" "" ""
## [238] "" "" ""
## [241] "" "" ""
## [244] "" "" ""
## [247] "" "" ""
## [250] "" "" ""
## [253] "" "" ""
## [256] "" "" ""
## [259] "" "" ""
## [262] "" "" ""
## [265] "" "" ""
## [268] "" "" ""
## [271] "" "" ""
## [274] "" "" ""
## [277] "" "" ""
## [280] "" "" ""
## [283] "" "" ""
## [286] "" "" ""
## [289] "" "" ""
## [292] "" "" ""
## [295] "" "" ""
## [298] "" "" ""
## [301] "" "" ""
## [304] "" "" ""
## [307] "" "" ""
## [310] "" "" ""
## [313] "" "" ""
## [316] "" "" ""
## [319] "" "" ""
## [322] "" "" ""
## [325] "" "" ""
## [328] "" "" ""
## [331] "" "" ""
## [334] "" "" ""
## [337] "" "" ""
## [340] "" "" ""
## [343] "" "" ""
## [346] "" "" ""
## [349] "" "" ""
## [352] "" "" ""
## [355] "" "" ""
## [358] "" "" ""
## [361] "" "" ""
## [364] "" "" ""
## [367] "" "" ""
## [370] "" "" ""
## [373] "" "" ""
## [376] "" "" ""
## [379] "" "" ""
## [382] "" "" ""
## [385] "" "" ""
## [388] "" "" ""
## [391] "" "" ""
## [394] "" "" ""
## [397] "" "" ""
## [400] "" "" ""
## [403] "" "" ""
## [406] "" "" ""
## [409] "" "" ""
## [412] "" "" ""
## [415] "" "" ""
## [418] "" "" ""
## [421] "" "" ""
## [424] "" "" ""
## [427] "" "" ""
## [430] "" "" ""
## [433] "" "" ""
## [436] "" "" ""
## [439] "" "" ""
## [442] "" "" ""
## [445] "" "" ""
## [448] "" "" ""
## [451] "" "" ""
## [454] "" "" ""
## [457] "" "" ""
## [460] "" "" ""
## [463] "" "" ""
## [466] "" "" ""
## [469] "" "" ""
## [472] "" "" ""
## [475] "" "" ""
## [478] "" "" ""
## [481] "" "" ""
## [484] "" "" ""
## [487] "" "" ""
## [490] "" "" ""
## [493] "" "" ""
## [496] "" "" ""
dataset$eating_changes<-replace( dataset$eating_changes, is.na(dataset$eating_changes),"no changes")
dataset$eating_changes
## [1] "eat faster" "eat out more" "eat faster"
## [4] "cheaper food" "no changes" "eat out more"
## [7] "eat healthier" "eat healthier" "eat healthier"
## [10] "eat out more" "no changes" "eat less"
## [13] "eat healthier" "less healthier" "eat healthier"
## [16] "no changes" "More Water" "eat healthier"
## [19] "eat out more" "no changes" "eat more"
## [22] "eat less" "eat out more" "eat less"
## [25] "eat more" "no changes" "eat out more"
## [28] "eat healthier" "eat healthier" "eat healthier"
## [31] "eat healthier" "no changes" "eat out more"
## [34] "eat out more" "eat less" "eat less"
## [37] "eat less" "eat out more" "eat more"
## [40] "eat more" "no changes" "eat out more"
## [43] "eat out more" "eat healthier" " no changes"
## [46] "eat less" "eat out more" "eat less"
## [49] "eat out more" "eat less healthier" "eat healthier"
## [52] "Mediocre " "eat less" "no changes"
## [55] "eat healthier" "eat on time" "eat healthier"
## [58] "eat faster " "eat more" "eat more"
## [61] "eat more" "eat healthier" "eat healthier"
## [64] "no changes" "eat out more" "eat out more"
## [67] "eat more out" "eat out more" "eat out more"
## [70] "eat healthier" "eat less" "eat out more"
## [73] "eat out more" "More Water " "no changes"
## [76] "eat less healthier" "eat less healthier" "eat more"
## [79] "eat less" "more coffee" "less healthier"
## [82] "no changes" "less healthier" "eat more "
## [85] "eat healthier" "eat more" "eat less"
## [88] "less healthier" "eat healthier" "eat healthier"
## [91] "eat healthier" "eat out more" "eat healthier"
## [94] "eat more" "eat more" "eat more"
## [97] "eat healthier" "eat healthier" "less healthier"
## [100] "eat healthier" "eat healthier" "eat more"
## [103] "eat healthier" "eat more" "eat more"
## [106] "eat less" "More Water " "eat more"
## [109] "eat more" "eat healthier" "eat out more"
## [112] "eat healthier" "eat healthier" "eat out more"
## [115] "unstable" "eat more" "less healthier"
## [118] "eat healthier" "eat healthier" "eat healthier"
## [121] "eat out more" "eat out more" "eat less"
## [124] "eat less" "eat healthier" ""
## [127] "" "" ""
## [130] "" "" ""
## [133] "" "" ""
## [136] "" "" ""
## [139] "" "" ""
## [142] "" "" ""
## [145] "" "" ""
## [148] "" "" ""
## [151] "" "" ""
## [154] "" "" ""
## [157] "" "" ""
## [160] "" "" ""
## [163] "" "" ""
## [166] "" "" ""
## [169] "" "" ""
## [172] "" "" ""
## [175] "" "" ""
## [178] "" "" ""
## [181] "" "" ""
## [184] "" "" ""
## [187] "" "" ""
## [190] "" "" ""
## [193] "" "" ""
## [196] "" "" ""
## [199] "" "" ""
## [202] "" "" ""
## [205] "" "" ""
## [208] "" "" ""
## [211] "" "" ""
## [214] "" "" ""
## [217] "" "" ""
## [220] "" "" ""
## [223] "" "" ""
## [226] "" "" ""
## [229] "" "" ""
## [232] "" "" ""
## [235] "" "" ""
## [238] "" "" ""
## [241] "" "" ""
## [244] "" "" ""
## [247] "" "" ""
## [250] "" "" ""
## [253] "" "" ""
## [256] "" "" ""
## [259] "" "" ""
## [262] "" "" ""
## [265] "" "" ""
## [268] "" "" ""
## [271] "" "" ""
## [274] "" "" ""
## [277] "" "" ""
## [280] "" "" ""
## [283] "" "" ""
## [286] "" "" ""
## [289] "" "" ""
## [292] "" "" ""
## [295] "" "" ""
## [298] "" "" ""
## [301] "" "" ""
## [304] "" "" ""
## [307] "" "" ""
## [310] "" "" ""
## [313] "" "" ""
## [316] "" "" ""
## [319] "" "" ""
## [322] "" "" ""
## [325] "" "" ""
## [328] "" "" ""
## [331] "" "" ""
## [334] "" "" ""
## [337] "" "" ""
## [340] "" "" ""
## [343] "" "" ""
## [346] "" "" ""
## [349] "" "" ""
## [352] "" "" ""
## [355] "" "" ""
## [358] "" "" ""
## [361] "" "" ""
## [364] "" "" ""
## [367] "" "" ""
## [370] "" "" ""
## [373] "" "" ""
## [376] "" "" ""
## [379] "" "" ""
## [382] "" "" ""
## [385] "" "" ""
## [388] "" "" ""
## [391] "" "" ""
## [394] "" "" ""
## [397] "" "" ""
## [400] "" "" ""
## [403] "" "" ""
## [406] "" "" ""
## [409] "" "" ""
## [412] "" "" ""
## [415] "" "" ""
## [418] "" "" ""
## [421] "" "" ""
## [424] "" "" ""
## [427] "" "" ""
## [430] "" "" ""
## [433] "" "" ""
## [436] "" "" ""
## [439] "" "" ""
## [442] "" "" ""
## [445] "" "" ""
## [448] "" "" ""
## [451] "" "" ""
## [454] "" "" ""
## [457] "" "" ""
## [460] "" "" ""
## [463] "" "" ""
## [466] "" "" ""
## [469] "" "" ""
## [472] "" "" ""
## [475] "" "" ""
## [478] "" "" ""
## [481] "" "" ""
## [484] "" "" ""
## [487] "" "" ""
## [490] "" "" ""
## [493] "" "" ""
## [496] "" "" ""
#Replace any student mentioning his status income with 1 which is very poor and he/she may got embarrassed to answer
dataset$income<-replace( dataset$income, is.na(dataset$income),1)
dataset$eating_changes
## [1] "eat faster" "eat out more" "eat faster"
## [4] "cheaper food" "no changes" "eat out more"
## [7] "eat healthier" "eat healthier" "eat healthier"
## [10] "eat out more" "no changes" "eat less"
## [13] "eat healthier" "less healthier" "eat healthier"
## [16] "no changes" "More Water" "eat healthier"
## [19] "eat out more" "no changes" "eat more"
## [22] "eat less" "eat out more" "eat less"
## [25] "eat more" "no changes" "eat out more"
## [28] "eat healthier" "eat healthier" "eat healthier"
## [31] "eat healthier" "no changes" "eat out more"
## [34] "eat out more" "eat less" "eat less"
## [37] "eat less" "eat out more" "eat more"
## [40] "eat more" "no changes" "eat out more"
## [43] "eat out more" "eat healthier" " no changes"
## [46] "eat less" "eat out more" "eat less"
## [49] "eat out more" "eat less healthier" "eat healthier"
## [52] "Mediocre " "eat less" "no changes"
## [55] "eat healthier" "eat on time" "eat healthier"
## [58] "eat faster " "eat more" "eat more"
## [61] "eat more" "eat healthier" "eat healthier"
## [64] "no changes" "eat out more" "eat out more"
## [67] "eat more out" "eat out more" "eat out more"
## [70] "eat healthier" "eat less" "eat out more"
## [73] "eat out more" "More Water " "no changes"
## [76] "eat less healthier" "eat less healthier" "eat more"
## [79] "eat less" "more coffee" "less healthier"
## [82] "no changes" "less healthier" "eat more "
## [85] "eat healthier" "eat more" "eat less"
## [88] "less healthier" "eat healthier" "eat healthier"
## [91] "eat healthier" "eat out more" "eat healthier"
## [94] "eat more" "eat more" "eat more"
## [97] "eat healthier" "eat healthier" "less healthier"
## [100] "eat healthier" "eat healthier" "eat more"
## [103] "eat healthier" "eat more" "eat more"
## [106] "eat less" "More Water " "eat more"
## [109] "eat more" "eat healthier" "eat out more"
## [112] "eat healthier" "eat healthier" "eat out more"
## [115] "unstable" "eat more" "less healthier"
## [118] "eat healthier" "eat healthier" "eat healthier"
## [121] "eat out more" "eat out more" "eat less"
## [124] "eat less" "eat healthier" ""
## [127] "" "" ""
## [130] "" "" ""
## [133] "" "" ""
## [136] "" "" ""
## [139] "" "" ""
## [142] "" "" ""
## [145] "" "" ""
## [148] "" "" ""
## [151] "" "" ""
## [154] "" "" ""
## [157] "" "" ""
## [160] "" "" ""
## [163] "" "" ""
## [166] "" "" ""
## [169] "" "" ""
## [172] "" "" ""
## [175] "" "" ""
## [178] "" "" ""
## [181] "" "" ""
## [184] "" "" ""
## [187] "" "" ""
## [190] "" "" ""
## [193] "" "" ""
## [196] "" "" ""
## [199] "" "" ""
## [202] "" "" ""
## [205] "" "" ""
## [208] "" "" ""
## [211] "" "" ""
## [214] "" "" ""
## [217] "" "" ""
## [220] "" "" ""
## [223] "" "" ""
## [226] "" "" ""
## [229] "" "" ""
## [232] "" "" ""
## [235] "" "" ""
## [238] "" "" ""
## [241] "" "" ""
## [244] "" "" ""
## [247] "" "" ""
## [250] "" "" ""
## [253] "" "" ""
## [256] "" "" ""
## [259] "" "" ""
## [262] "" "" ""
## [265] "" "" ""
## [268] "" "" ""
## [271] "" "" ""
## [274] "" "" ""
## [277] "" "" ""
## [280] "" "" ""
## [283] "" "" ""
## [286] "" "" ""
## [289] "" "" ""
## [292] "" "" ""
## [295] "" "" ""
## [298] "" "" ""
## [301] "" "" ""
## [304] "" "" ""
## [307] "" "" ""
## [310] "" "" ""
## [313] "" "" ""
## [316] "" "" ""
## [319] "" "" ""
## [322] "" "" ""
## [325] "" "" ""
## [328] "" "" ""
## [331] "" "" ""
## [334] "" "" ""
## [337] "" "" ""
## [340] "" "" ""
## [343] "" "" ""
## [346] "" "" ""
## [349] "" "" ""
## [352] "" "" ""
## [355] "" "" ""
## [358] "" "" ""
## [361] "" "" ""
## [364] "" "" ""
## [367] "" "" ""
## [370] "" "" ""
## [373] "" "" ""
## [376] "" "" ""
## [379] "" "" ""
## [382] "" "" ""
## [385] "" "" ""
## [388] "" "" ""
## [391] "" "" ""
## [394] "" "" ""
## [397] "" "" ""
## [400] "" "" ""
## [403] "" "" ""
## [406] "" "" ""
## [409] "" "" ""
## [412] "" "" ""
## [415] "" "" ""
## [418] "" "" ""
## [421] "" "" ""
## [424] "" "" ""
## [427] "" "" ""
## [430] "" "" ""
## [433] "" "" ""
## [436] "" "" ""
## [439] "" "" ""
## [442] "" "" ""
## [445] "" "" ""
## [448] "" "" ""
## [451] "" "" ""
## [454] "" "" ""
## [457] "" "" ""
## [460] "" "" ""
## [463] "" "" ""
## [466] "" "" ""
## [469] "" "" ""
## [472] "" "" ""
## [475] "" "" ""
## [478] "" "" ""
## [481] "" "" ""
## [484] "" "" ""
## [487] "" "" ""
## [490] "" "" ""
## [493] "" "" ""
## [496] "" "" ""
#Categorize the student status of income
dataset$income=factor(dataset$income, levels = c( "1","2","3","4","5","6"), labels=c("very poor","poor", "average","good","high","very high"))
dataset$income
## [1] high good very high very high very high very poor good
## [8] high high good average high high high
## [15] high good very poor very high high high very high
## [22] very high very high good good very high high very high
## [29] high high high good high average very high
## [36] good very high very high high very high very high average
## [43] very high average high very high good very high high
## [50] average very poor very high high average very high average
## [57] very high high high very high very high good very high
## [64] high poor very high good high very high very high
## [71] average high high very high average high average
## [78] average high very high good good average very poor
## [85] high very high very high very high poor average very high
## [92] very high average good very high high very high high
## [99] very high good poor high very poor good high
## [106] good very poor good very high very high average high
## [113] very high very high average very high very poor poor average
## [120] poor good poor poor good high very poor
## [127] very poor very poor very poor very poor very poor very poor very poor
## [134] very poor very poor very poor very poor very poor very poor very poor
## [141] very poor very poor very poor very poor very poor very poor very poor
## [148] very poor very poor very poor very poor very poor very poor very poor
## [155] very poor very poor very poor very poor very poor very poor very poor
## [162] very poor very poor very poor very poor very poor very poor very poor
## [169] very poor very poor very poor very poor very poor very poor very poor
## [176] very poor very poor very poor very poor very poor very poor very poor
## [183] very poor very poor very poor very poor very poor very poor very poor
## [190] very poor very poor very poor very poor very poor very poor very poor
## [197] very poor very poor very poor very poor very poor very poor very poor
## [204] very poor very poor very poor very poor very poor very poor very poor
## [211] very poor very poor very poor very poor very poor very poor very poor
## [218] very poor very poor very poor very poor very poor very poor very poor
## [225] very poor very poor very poor very poor very poor very poor very poor
## [232] very poor very poor very poor very poor very poor very poor very poor
## [239] very poor very poor very poor very poor very poor very poor very poor
## [246] very poor very poor very poor very poor very poor very poor very poor
## [253] very poor very poor very poor very poor very poor very poor very poor
## [260] very poor very poor very poor very poor very poor very poor very poor
## [267] very poor very poor very poor very poor very poor very poor very poor
## [274] very poor very poor very poor very poor very poor very poor very poor
## [281] very poor very poor very poor very poor very poor very poor very poor
## [288] very poor very poor very poor very poor very poor very poor very poor
## [295] very poor very poor very poor very poor very poor very poor very poor
## [302] very poor very poor very poor very poor very poor very poor very poor
## [309] very poor very poor very poor very poor very poor very poor very poor
## [316] very poor very poor very poor very poor very poor very poor very poor
## [323] very poor very poor very poor very poor very poor very poor very poor
## [330] very poor very poor very poor very poor very poor very poor very poor
## [337] very poor very poor very poor very poor very poor very poor very poor
## [344] very poor very poor very poor very poor very poor very poor very poor
## [351] very poor very poor very poor very poor very poor very poor very poor
## [358] very poor very poor very poor very poor very poor very poor very poor
## [365] very poor very poor very poor very poor very poor very poor very poor
## [372] very poor very poor very poor very poor very poor very poor very poor
## [379] very poor very poor very poor very poor very poor very poor very poor
## [386] very poor very poor very poor very poor very poor very poor very poor
## [393] very poor very poor very poor very poor very poor very poor very poor
## [400] very poor very poor very poor very poor very poor very poor very poor
## [407] very poor very poor very poor very poor very poor very poor very poor
## [414] very poor very poor very poor very poor very poor very poor very poor
## [421] very poor very poor very poor very poor very poor very poor very poor
## [428] very poor very poor very poor very poor very poor very poor very poor
## [435] very poor very poor very poor very poor very poor very poor very poor
## [442] very poor very poor very poor very poor very poor very poor very poor
## [449] very poor very poor very poor very poor very poor very poor very poor
## [456] very poor very poor very poor very poor very poor very poor very poor
## [463] very poor very poor very poor very poor very poor very poor very poor
## [470] very poor very poor very poor very poor very poor very poor very poor
## [477] very poor very poor very poor very poor very poor very poor very poor
## [484] very poor very poor very poor very poor very poor very poor very poor
## [491] very poor very poor very poor very poor very poor very poor very poor
## [498] very poor
## Levels: very poor poor average good high very high
#Replace any weight in 0 KG with NA to overcome errors in the calculations
dataset$weightINKG<-replace( dataset$weightINKG, dataset$weightINKG==0,NA)
dataset$weightINKG
## [1] 85.00000 70.45455 NA NA 86.36364 86.36364 81.81818
## [8] 62.27273 81.81818 56.81818 52.72727 50.00000 120.00000 55.90909
## [15] 84.09091 81.81818 65.90909 77.27273 61.36364 75.00000 79.54545
## [22] 88.63636 84.09091 84.09091 47.72727 56.81818 72.72727 79.54545
## [29] 81.81818 75.90909 52.27273 93.18182 NaN 58.18182 68.18182
## [36] 68.18182 68.18182 77.27273 68.18182 79.54545 63.63636 54.54545
## [43] 61.36364 45.45455 77.27273 51.36364 76.36364 65.90909 70.45455
## [50] 68.18182 76.81818 84.09091 90.90909 120.45455 75.00000 87.27273
## [57] 79.54545 63.63636 70.45455 70.45455 61.36364 53.63636 95.45455
## [64] 81.81818 63.63636 50.90909 56.81818 NA 65.90909 59.09091
## [71] 63.63636 63.63636 63.63636 90.90909 NaN 54.54545 68.18182
## [78] 90.90909 61.36364 65.90909 59.09091 86.36364 77.27273 57.72727
## [85] 75.90909 63.63636 86.36364 70.45455 79.54545 58.63636 118.18182
## [92] 61.36364 86.36364 75.00000 79.54545 83.63636 95.45455 70.45455
## [99] 84.09091 75.00000 56.81818 72.72727 61.36364 59.09091 104.54545
## [106] 56.81818 59.09091 75.00000 58.18182 90.90909 72.72727 77.27273
## [113] 58.63636 77.27273 62.72727 68.18182 77.27273 51.36364 63.63636
## [120] 84.09091 70.90909 81.81818 54.54545 61.36364 61.36364 NA
## [127] NA NA NA NA NA NA NA
## [134] NA NA NA NA NA NA NA
## [141] NA NA NA NA NA NA NA
## [148] NA NA NA NA NA NA NA
## [155] NA NA NA NA NA NA NA
## [162] NA NA NA NA NA NA NA
## [169] NA NA NA NA NA NA NA
## [176] NA NA NA NA NA NA NA
## [183] NA NA NA NA NA NA NA
## [190] NA NA NA NA NA NA NA
## [197] NA NA NA NA NA NA NA
## [204] NA NA NA NA NA NA NA
## [211] NA NA NA NA NA NA NA
## [218] NA NA NA NA NA NA NA
## [225] NA NA NA NA NA NA NA
## [232] NA NA NA NA NA NA NA
## [239] NA NA NA NA NA NA NA
## [246] NA NA NA NA NA NA NA
## [253] NA NA NA NA NA NA NA
## [260] NA NA NA NA NA NA NA
## [267] NA NA NA NA NA NA NA
## [274] NA NA NA NA NA NA NA
## [281] NA NA NA NA NA NA NA
## [288] NA NA NA NA NA NA NA
## [295] NA NA NA NA NA NA NA
## [302] NA NA NA NA NA NA NA
## [309] NA NA NA NA NA NA NA
## [316] NA NA NA NA NA NA NA
## [323] NA NA NA NA NA NA NA
## [330] NA NA NA NA NA NA NA
## [337] NA NA NA NA NA NA NA
## [344] NA NA NA NA NA NA NA
## [351] NA NA NA NA NA NA NA
## [358] NA NA NA NA NA NA NA
## [365] NA NA NA NA NA NA NA
## [372] NA NA NA NA NA NA NA
## [379] NA NA NA NA NA NA NA
## [386] NA NA NA NA NA NA NA
## [393] NA NA NA NA NA NA NA
## [400] NA NA NA NA NA NA NA
## [407] NA NA NA NA NA NA NA
## [414] NA NA NA NA NA NA NA
## [421] NA NA NA NA NA NA NA
## [428] NA NA NA NA NA NA NA
## [435] NA NA NA NA NA NA NA
## [442] NA NA NA NA NA NA NA
## [449] NA NA NA NA NA NA NA
## [456] NA NA NA NA NA NA NA
## [463] NA NA NA NA NA NA NA
## [470] NA NA NA NA NA NA NA
## [477] NA NA NA NA NA NA NA
## [484] NA NA NA NA NA NA NA
## [491] NA NA NA NA NA NA NA
## [498] NA
The main concern for calories reduction is to analyze the amount of calories that each student lose when he/she do exercise from the total calories that enter his/her body daily.
CaloriesReduction<- function(x,y) {
Excercise<-dataset$exercise
y<-Excercise*500
x<-dataset$IntcaloriesSum
TotalCalories<- x-y
return (TotalCalories)
}
While exploring data we recognized several things about the students food choices.
First of all we conducted that the majority students who do 1 exercise per week takes vitamins by 51%, while the students who do not take vitamins are 49% percent. But the majority students who do 2 exercises per week do not take vitamins by 57%, and the students who take vitamins are only 43%. The majority of students who do 3 exercises per week takes vitamins by 55% which is the highest among all other exercises percentages, and the students who do not take vitamins are 45%. This means that vitamins has a role for students who do exercises. In a matter of fact the beginners are most probably needing energy to exercise, so they take vitamins and the experts who do 3 exercises per week needs more energy while exercising.
Students studying hours also is affected by whether they drink coffee or not. Majority of students with studying hours less than 60 minutes, between 60 minutes and 180 minutes do not drink coffee a lot. While the majority of students with 240 minutes of studying likes drinking coffee;however, students who exceeds 300 minutes of studying do not prefer drinking coffee and the last which were students who study for 360 minutes were in a tie which no one prefers neither hate drinking coffee. This indicates that students who study between 4-5 hours are coffee lovers.
Students who play 2 sports have less GPA than the students who play 1 sports.Showing that academic performance may get affected by playing more than 1 sport
#Data exploration
#the probability of num of exercises for students who take or not take vitamins
table1<-table(dataset$exercise,dataset$vitamins)
round(prop.table(table1,1),2)
##
## Yes NO
## 1 0.51 0.49
## 2 0.43 0.57
## 3 0.55 0.45
#the probability of students' studying hrs who prefer drinking coffee
table2<-table(dataset$Studying_hrs,dataset$coffee)
round(prop.table(table2,1),2)
##
## 1 2
## 0.266043663
## 0.268722097 1 0
## 0.438171567
## 0.458377574
## 0.546190176
## 0.548365189
## 0.628942061
## 0.654242148
## 0.669715948 1 0
## 0.685848874
## 0.686920849
## 0.688090581
## 0.688909231
## 0.698459965
## 0.727221191 0 1
## 0.73163629
## 0.771286567 0 1
## 0.846505526
## 0.859499052 0 1
## 0.898732803
## 0.953412996 0 1
## 0.968527327
## 0.971332454
## 0.97288292 0 1
## 0.987603172
## 0.992917365
## 1.065623809
## 1.095999271
## 1.145295813
## 1.200785525 1 0
## 1.226298134
## 1.228773184
## 1.231167524 1 0
## 1.245785944
## 1.265488916 1 0
## 1.294136576
## 1.295427294
## 1.308487263 0 1
## 1.312758977
## 1.353317341
## 1.357373136
## 1.384044112
## 1.410229567
## 1.415034656 0 1
## 1.416661055
## 1.424450548
## 1.437876724
## 1.438596105
## 1.445798858 0 1
## 1.46061633
## 1.461144421
## 1.478787199
## 1.497024128 0 1
## 1.502211626
## 1.511205108
## 1.524782291
## 1.529560944
## 1.558422563 0 1
## 1.560355376
## 1.571949813
## 1.590355862 0 1
## 1.606072357 1 0
## 1.616607435
## 1.619226127
## 1.625268393
## 1.627695089
## 1.631261107
## 1.644636603
## 1.662253199
## 1.67239058 0 1
## 1.680997133
## 1.690458095
## 1.723593561
## 1.748651124
## 1.759698667
## 1.775932552 0 1
## 1.788176341
## 1.790342317
## 1.791753568
## 1.798718303
## 1.817889113
## 1.839802006
## 1.843675775
## 1.852117711
## 1.853347613
## 1.857541886
## 1.871957854
## 1.877147043
## 1.89355686 0 1
## 1.907136833 1 0
## 1.919511103
## 1.927578829 0 1
## 1.945961053
## 1.965635933
## 1.981809911
## 1.999325527 0 1
## 2.003926093
## 2.009046461 0 1
## 2.017513588
## 2.030297043
## 2.042739312
## 2.060794311 0 1
## 2.070663768
## 2.089042355
## 2.09736906
## 2.100552494
## 2.115136485
## 2.152698433
## 2.155733626
## 2.155843323 0 1
## 2.169161261 0 1
## 2.176322145
## 2.188938121 0 1
## 2.191833702 0 1
## 2.192744863
## 2.19759212
## 2.200982172 0 1
## 2.208240516 0 1
## 2.220470327
## 2.233440584
## 2.239664992 0 1
## 2.246745707
## 2.250929414 0 1
## 2.253721516
## 2.260395693
## 2.282266934 0 1
## 2.295700142
## 2.311554237
## 2.312988055 0 1
## 2.314488983 1 0
## 2.32169769
## 2.325309226
## 2.336276033
## 2.351202468
## 2.363564669
## 2.391549999
## 2.391677519
## 2.39322812 0 1
## 2.399561326 0 1
## 2.400087291 0 1
## 2.408379902
## 2.410635566
## 2.413381753
## 2.421464669
## 2.435094856
## 2.453209061
## 2.457921707
## 2.458555872 0 1
## 2.465761128
## 2.466292344
## 2.468859994
## 2.473079377 0 1
## 2.480606467 0 1
## 2.48162387
## 2.517400876
## 2.535002113
## 2.546524587 1 0
## 2.572598203
## 2.575054857
## 2.576176307 1 0
## 2.576939959
## 2.579516515
## 2.58241664
## 2.584729022 0 1
## 2.646904537
## 2.666116035 1 0
## 2.667465435 0 1
## 2.679887318
## 2.714498038
## 2.71943218
## 2.727715712
## 2.734960056
## 2.740395407
## 2.768523129
## 2.769118126
## 2.779682627
## 2.784244545
## 2.791113803 0 1
## 2.798160728
## 2.799747487
## 2.821192645
## 2.841238677
## 2.842868351
## 2.847816843
## 2.857614364
## 2.861274444
## 2.890447416 0 1
## 2.898583142 0 1
## 2.901788592
## 2.923683874
## 2.942449872 1 0
## 2.944391335
## 2.946870435
## 2.947531471
## 2.958696801
## 2.961956663
## 2.96216821
## 2.967323268
## 2.968187102 1 0
## 2.977916724
## 2.994204284
## 3.020724447
## 3.026918175
## 3.031497066
## 3.036819937
## 3.040797294 1 0
## 3.056376653 0 1
## 3.05738784
## 3.067609453
## 3.078293381 0 1
## 3.092164648
## 3.09688561 0 1
## 3.11334209
## 3.126603239
## 3.135475154
## 3.156367436
## 3.157765091
## 3.158618594
## 3.16938024
## 3.172299463 0 1
## 3.175406147 0 1
## 3.192991809 0 1
## 3.20079786
## 3.201042435
## 3.217847363
## 3.225132752 1 0
## 3.227472173
## 3.233313747
## 3.261182104
## 3.26747544
## 3.31157823
## 3.313796516
## 3.315989476
## 3.31760678
## 3.342749396
## 3.344108372
## 3.348788206 0 1
## 3.357597382
## 3.35807157 1 0
## 3.393439153
## 3.407980039 0 1
## 3.415806479
## 3.426911652
## 3.427723163
## 3.433489759 0 1
## 3.451772538
## 3.452067233
## 3.453102739
## 3.468573793
## 3.47649914
## 3.481137767
## 3.483925685
## 3.492310186
## 3.509604688
## 3.514891782
## 3.515179177
## 3.539854127
## 3.543203654 0 1
## 3.550337184
## 3.552736964
## 3.554600317
## 3.56472374
## 3.565224319 1 0
## 3.567905233 0 1
## 3.570013567 0 1
## 3.571446511
## 3.577800675 1 0
## 3.581381038
## 3.583875162 0 1
## 3.596398318
## 3.615471053
## 3.618829789
## 3.61905549 0 1
## 3.629424387
## 3.64088397
## 3.661656456 0 1
## 3.670291526
## 3.688539518
## 3.691348189
## 3.69639041
## 3.703437932 0 1
## 3.706660981
## 3.710192978
## 3.722097639
## 3.730569958
## 3.737941605 0 1
## 3.739995796
## 3.749180727
## 3.751089281
## 3.751225463
## 3.752659492 0 1
## 3.752824766
## 3.75430142
## 3.757378987
## 3.773260652 0 1
## 3.776484631
## 3.802970673
## 3.802973633
## 3.804298861 1 0
## 3.822179643
## 3.822203964
## 3.822270313
## 3.823898686
## 3.835577646
## 3.837977768
## 3.857424259 0 1
## 3.872788848
## 3.901170334 0 1
## 3.941019322
## 3.960636371
## 3.961032766
## 3.96172964
## 3.966215411 0 1
## 3.98019535
## 3.981127739
## 3.988452835
## 3.990415894
## 3.999703007
## 4.000819183
## 4.004537739 0 1
## 4.017611208
## 4.030864938
## 4.035727019
## 4.039547986
## 4.056493099 0 1
## 4.058311616
## 4.078208838
## 4.083821161
## 4.087631183 1 0
## 4.105224517
## 4.109944653
## 4.121647747
## 4.130778265 1 0
## 4.155540864
## 4.1596093 0 1
## 4.159887144
## 4.169100759
## 4.179521023
## 4.199728526
## 4.206754912
## 4.209470573
## 4.212697339
## 4.216057592
## 4.229663345
## 4.234991215
## 4.245215597
## 4.250568064
## 4.253501304
## 4.258311529
## 4.261013003 1 0
## 4.261219972
## 4.284305558
## 4.28799968
## 4.307288416
## 4.317133158
## 4.317760919 0 1
## 4.321364297
## 4.324660384
## 4.328417097
## 4.337571452
## 4.36170927
## 4.374832318 0 1
## 4.37825945
## 4.391592976
## 4.396622319
## 4.397451275
## 4.400455145
## 4.402663195
## 4.425995084
## 4.45696361
## 4.477271392
## 4.486703665
## 4.501158336
## 4.503108168 1 0
## 4.50344538
## 4.51696059
## 4.540636147
## 4.550636958 0 1
## 4.553216548
## 4.56870456
## 4.570801127
## 4.57685653
## 4.590970461
## 4.59169701
## 4.599373404 0 1
## 4.600114757
## 4.633228732
## 4.633441055
## 4.633915057 1 0
## 4.649143652
## 4.656998572
## 4.658742683
## 4.658890392 0 1
## 4.660289961
## 4.661261209 0 1
## 4.68281699
## 4.691998851 0 1
## 4.708202988
## 4.719665333 0 1
## 4.720987338
## 4.737045954
## 4.754168395
## 4.758785492
## 4.760014333
## 4.767595639
## 4.79332516
## 4.795842867
## 4.802091807 0 1
## 4.808150425
## 4.810424058
## 4.81153338
## 4.820091247
## 4.821810262
## 4.826602696 1 0
## 4.827416304
## 4.833506427 0 1
## 4.853032519
## 4.877725538
## 4.902991575 0 1
## 4.909688469
## 4.927132625
## 4.932409978
## 4.933044092 0 1
## 4.93925896
## 4.940227777
## 4.981981125
## 4.985254927
## 4.98536659
## 5.010577427 0 1
## 5.029951665 0 1
## 5.032211034
## 5.034003785 0 1
## 5.034231009 0 1
## 5.040174582
## 5.046081775 0 1
## 5.068747881 0 1
## 5.079475899
## 5.085523011
## 5.097802509
## 5.132401469
## 5.135455316
## 5.151598289 0 1
## 5.15933124
## 5.21140132 0 1
## 5.231702968 0 1
## 5.231863313 1 0
## 5.239909498
## 5.265478958
## 5.275294151
## 5.313956903
## 5.323507389
## 5.335718004
## 5.34835294 1 0
## 5.362448263
## 5.367236103
## 5.368041173
## 5.380070207
## 5.381398471
## 5.381478737 0 1
## 5.386559329
## 5.498147193 0 1
## 5.506621537
## 5.522891668
## 5.538047529 1 0
## 5.562545475 1 0
## 5.588389336
## 5.596398273 0 1
## 5.60796663
## 5.638460387
## 5.683750561
## 5.713802294
## 5.743736081
## 5.747444104 0 1
## 5.767814366 0 1
## 5.836196656
## 5.890148697
## 5.910284878
## 5.9142477 1 0
## 5.915781395
## 5.923346071
## 5.949347502
## 5.950986328 0 1
## 5.951814099 0 1
## 5.960547308 0 1
## 5.963422086
## 6.004987475
## 6.064013048
## 6.086478284
## 6.160434101
## 6.186945609
## 6.196295546
## 6.236955312
## 6.281370191
## 6.299101259 0 1
## 6.359600004 1 0
## 6.384274497
## 6.618279842
## 6.863387951
#the probability of the students GPA along with number of sports that they play
table4<-table(dataset$GPAA, dataset$sports)
round(prop.table(table4,1),2)
##
## 1 2
## 2.2
## 2.25 0.00 1.00
## 2.4 1.00 0.00
## 2.6 0.50 0.50
## 2.71 0.00 1.00
## 2.8 0.80 0.20
## 2.9 0.00 1.00
## 3 0.70 0.30
## 3.1 0.67 0.33
## 3.2 0.45 0.55
## 3.292 0.00 1.00
## 3.3 0.70 0.30
## 3.35 1.00 0.00
## 3.4 0.44 0.56
## 3.5 0.71 0.29
## 3.6 0.57 0.43
## 3.605 0.00 1.00
## 3.63 0.00 1.00
## 3.65 1.00 0.00
## 3.654 0.50 0.50
## 3.67 0.00 1.00
## 3.68 1.00 0.00
## 3.7 0.90 0.10
## 3.73 1.00 0.00
## 3.75 1.00 0.00
## 3.77 0.00 1.00
## 3.8 0.67 0.33
## 3.83 0.50 0.50
## 3.87 1.00 0.00
## 3.882 0.00 1.00
## 3.89 1.00 0.00
## 3.9 0.57 0.43
## 3.904 1.00 0.00
## 3.92 0.00 1.00
## 4 0.50 0.50
H<-as.numeric(H)
H
## [1] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
## [19] 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
## [37] 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
## [55] 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
## [73] 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
## [91] 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
## [109] 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
## [127] 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
## [145] 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
## [163] 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
## [181] 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
## [199] 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
## [217] 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
## [235] 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
## [253] 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
## [271] 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
## [289] 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
## [307] 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
## [325] 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
## [343] 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
## [361] 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
## [379] 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
## [397] 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
## [415] 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
## [433] 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
## [451] 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
## [469] 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605
## [487] 606 607 608 609 610 611 612 613 614 615 616 617
w<-as.numeric(w)
## Warning: NAs introduced by coercion
BMI<- H/covertToKG(w)^2*703
dataset$BMI<-as.integer(BMI)
dataset$BMI
## [1] 11 17 NA NA 11 11 13 23 13 28 32 36 6 29 13 14 22 16 25 17 15 12 14 14 44
## [26] 31 19 16 15 18 38 12 NA 31 23 23 23 18 23 17 27 38 30 55 19 43 20 27 23 25
## [51] 20 17 14 8 21 16 19 30 25 25 33 44 14 19 31 50 40 NA 30 38 32 33 33 16 NA
## [76] 46 29 16 36 32 40 18 23 42 24 35 19 29 23 42 10 39 19 26 23 21 16 30 21 27
## [101] 47 29 41 44 14 48 45 28 47 19 30 27 47 27 41 35 27 63 41 23 33 25 57 45 45
## [126] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [151] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [176] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [201] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [226] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [251] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [276] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [301] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [326] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [351] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [376] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [401] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [426] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [451] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [476] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
z<-1
for (z in 1:488){
if (isTRUE(dataset$BMI[z]<18.5)){
print( BMI[z]<-"underweight")
}
else if (isTRUE(dataset$BMI[z]<25)){
print( BMI[z]<-"NOrmal")
}
else if ( isTRUE(dataset$BMI[z]<30) ){
print( BMI[z]<-"Overweight")
}
else {
print( BMI[z]<-"Obese")
}
dataset$BMI[z]
}
## [1] "underweight"
## [1] "underweight"
## [1] "Obese"
## [1] "Obese"
## [1] "underweight"
## [1] "underweight"
## [1] "underweight"
## [1] "NOrmal"
## [1] "underweight"
## [1] "Overweight"
## [1] "Obese"
## [1] "Obese"
## [1] "underweight"
## [1] "Overweight"
## [1] "underweight"
## [1] "underweight"
## [1] "NOrmal"
## [1] "underweight"
## [1] "Overweight"
## [1] "underweight"
## [1] "underweight"
## [1] "underweight"
## [1] "underweight"
## [1] "underweight"
## [1] "Obese"
## [1] "Obese"
## [1] "NOrmal"
## [1] "underweight"
## [1] "underweight"
## [1] "underweight"
## [1] "Obese"
## [1] "underweight"
## [1] "Obese"
## [1] "Obese"
## [1] "NOrmal"
## [1] "NOrmal"
## [1] "NOrmal"
## [1] "underweight"
## [1] "NOrmal"
## [1] "underweight"
## [1] "Overweight"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Overweight"
## [1] "NOrmal"
## [1] "Overweight"
## [1] "NOrmal"
## [1] "underweight"
## [1] "underweight"
## [1] "underweight"
## [1] "NOrmal"
## [1] "underweight"
## [1] "NOrmal"
## [1] "Obese"
## [1] "Overweight"
## [1] "Overweight"
## [1] "Obese"
## [1] "Obese"
## [1] "underweight"
## [1] "NOrmal"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "underweight"
## [1] "Obese"
## [1] "Obese"
## [1] "Overweight"
## [1] "underweight"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "underweight"
## [1] "NOrmal"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Overweight"
## [1] "NOrmal"
## [1] "Obese"
## [1] "underweight"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Overweight"
## [1] "NOrmal"
## [1] "NOrmal"
## [1] "underweight"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Overweight"
## [1] "Obese"
## [1] "Overweight"
## [1] "Obese"
## [1] "Obese"
## [1] "underweight"
## [1] "Obese"
## [1] "Obese"
## [1] "Overweight"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Obese"
## [1] "Overweight"
## [1] "Obese"
## [1] "Overweight"
## [1] "Obese"
## [1] "Obese"
## [1] "Overweight"
## [1] "Obese"
## [1] "Obese"
## [1] "NOrmal"
## [1] "Obese"
## [1] "Overweight"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
## [1] "Obese"
z<-1
dataset$BMI
## [1] 11 17 NA NA 11 11 13 23 13 28 32 36 6 29 13 14 22 16 25 17 15 12 14 14 44
## [26] 31 19 16 15 18 38 12 NA 31 23 23 23 18 23 17 27 38 30 55 19 43 20 27 23 25
## [51] 20 17 14 8 21 16 19 30 25 25 33 44 14 19 31 50 40 NA 30 38 32 33 33 16 NA
## [76] 46 29 16 36 32 40 18 23 42 24 35 19 29 23 42 10 39 19 26 23 21 16 30 21 27
## [101] 47 29 41 44 14 48 45 28 47 19 30 27 47 27 41 35 27 63 41 23 33 25 57 45 45
## [126] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [151] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [176] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [201] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [226] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [251] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [276] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [301] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [326] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [351] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [376] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [401] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [426] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [451] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [476] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
The following are ranks for students exercises ,BMI AND GPAA
#
#ranking Students Exercise
rank(dataset$exercise,na.last = TRUE,ties.method = c("min"))
## [1] 1 1 58 102 1 58 1 58 113 1 1 1 102 58 58 1 58 1
## [19] 102 58 1 1 1 102 114 1 1 1 58 58 58 58 115 102 1 1
## [37] 1 102 58 1 1 1 116 117 1 118 58 1 1 58 1 1 1 119
## [55] 1 1 1 1 58 120 1 58 1 1 1 58 121 58 1 58 58 1
## [73] 58 1 58 1 58 58 1 1 58 1 1 122 1 102 58 1 1 1
## [91] 1 58 102 102 1 1 58 1 58 123 58 102 1 58 124 58 58 1
## [109] 1 102 58 58 1 58 58 1 58 125 58 58 58 58 58 1 58 126
## [127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
## [145] 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
## [163] 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
## [181] 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
## [199] 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
## [217] 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
## [235] 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
## [253] 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
## [271] 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
## [289] 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
## [307] 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
## [325] 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
## [343] 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
## [361] 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
## [379] 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
## [397] 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
## [415] 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
## [433] 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
## [451] 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
## [469] 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
## [487] 487 488 489 490 491 492 493 494 495 496 497 498
#ranking Students BMI
rank(dataset$BMI,na.last = TRUE,ties.method = c("min"))
## [1] 4 26 121 122 4 4 9 46 9 69 83 92 1 71 9 12 45 20
## [19] 57 26 18 7 12 12 106 80 33 20 18 30 94 7 123 80 46 46
## [37] 46 30 46 26 63 94 75 118 33 105 40 63 46 57 40 26 12 2
## [55] 42 20 33 75 57 57 86 106 12 33 80 117 98 124 75 94 83 86
## [73] 86 20 125 112 71 20 92 83 98 30 46 103 56 90 33 71 46 103
## [91] 3 97 33 62 46 42 20 75 42 63 113 71 100 106 12 116 109 69
## [109] 113 33 75 63 113 63 100 90 63 120 100 46 86 57 119 109 109 126
## [127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
## [145] 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
## [163] 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
## [181] 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
## [199] 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
## [217] 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
## [235] 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
## [253] 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
## [271] 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
## [289] 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
## [307] 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
## [325] 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
## [343] 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
## [361] 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
## [379] 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
## [397] 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
## [415] 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
## [433] 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
## [451] 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
## [469] 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
## [487] 487 488 489 490 491 492 493 494 495 496 497 498
#ranking Students 'PA
rank(dataset$GPAA,ties.method = c("min"))
## [1] 10 335 157 112 239 5 400 157 157 157 239 473 201 293 99 10 482 293
## [19] 201 1 157 433 348 348 445 27 348 55 112 239 482 482 201 27 331 55
## [37] 348 201 441 55 201 47 293 239 112 323 400 27 239 425 293 157 157 153
## [55] 239 197 400 27 239 348 293 335 445 15 239 112 55 293 112 340 388 482
## [73] 99 157 23 55 348 99 55 445 201 239 348 348 425 15 55 112 239 112
## [91] 344 400 157 112 392 239 478 445 445 112 239 201 112 348 239 55 55 400
## [109] 400 201 348 47 445 293 27 157 201 396 327 112 239 55 437 55 445 5
## [127] 400 157 157 157 239 473 201 293 99 482 293 201 1 157 433 348 348 445
## [145] 27 348 55 112 239 482 482 201 27 331 55 348 201 441 55 201 47 293
## [163] 239 112 323 400 27 239 425 293 157 157 153 239 197 400 27 239 348 293
## [181] 445 15 239 112 55 293 112 340 388 482 99 23 55 348 99 55 445 201
## [199] 239 348 348 425 15 55 112 239 112 344 400 157 112 392 239 478 445 445
## [217] 112 239 201 348 55 55 400 400 201 348 47 445 293 27 157 201 396 327
## [235] 112 239 55 437 55 445 10 335 157 112 239 5 400 157 157 157 239 473
## [253] 201 293 99 482 293 201 1 157 433 348 348 445 27 348 55 112 239 482
## [271] 482 201 27 331 55 348 201 441 55 201 47 293 239 112 323 400 27 239
## [289] 425 293 157 157 153 239 197 400 27 239 348 293 445 15 239 112 55 293
## [307] 112 340 388 482 99 23 55 348 99 55 445 201 239 348 348 425 15 55
## [325] 112 239 112 344 400 157 112 392 239 478 445 445 112 239 201 348 55 55
## [343] 400 400 201 348 47 445 293 27 157 201 396 327 112 239 55 437 55 445
## [361] 10 335 157 112 239 5 400 157 157 157 239 473 201 293 99 482 293 201
## [379] 1 157 433 348 348 445 27 348 55 112 239 482 482 201 27 331 55 348
## [397] 201 441 55 201 47 293 239 112 323 400 27 239 425 293 157 157 153 239
## [415] 197 400 27 239 348 293 445 15 239 112 55 293 112 340 388 482 99 23
## [433] 55 348 99 55 445 201 239 348 348 425 15 55 112 239 112 344 400 157
## [451] 112 392 239 478 445 445 112 239 201 348 55 55 400 400 201 348 47 445
## [469] 293 27 157 201 396 327 112 239 55 437 55 445 10 335 157 112 239 5
## [487] 400 157 157 157 239 473 201 293 99 482 293 201
#ranking FavFood according to the carbon foot print table
rank(dataset$fav_food,na.last = TRUE,ties.method = c("min"))
## [1] 1 1 251 441 446 292 1 1 292 451 1 1 292 455 292 251 1 292
## [19] 292 459 292 251 1 1 437 292 1 1 1 463 463 1 1 1 292 1
## [37] 292 1 1 1 1 1 1 292 1 1 1 292 1 471 471 479 1 292
## [55] 1 1 1 292 1 292 1 251 1 1 292 292 1 1 1 483 1 1
## [73] 487 1 251 1 292 251 491 495 292 1 1 1 292 292 292 251 1 1
## [91] 1 292 1 1 1 292 292 1 1 1 1 292 292 1 292 292 1 292
## [109] 251 251 1 1 292 1 292 292 251 292 1 292 1 1 1 292 1 251
## [127] 441 446 292 1 1 292 451 1 1 292 455 292 251 1 292 292 459 292
## [145] 251 1 1 437 292 1 1 1 463 463 1 1 292 1 292 1 1 1
## [163] 1 1 1 292 1 1 1 292 1 471 471 479 1 292 1 1 1 292
## [181] 1 292 1 251 1 1 292 292 1 1 1 483 1 1 487 1 251 1
## [199] 292 251 491 495 292 1 1 1 292 292 292 251 1 1 1 292 1 1
## [217] 1 292 292 1 1 1 292 292 1 292 292 1 292 251 251 1 1 292
## [235] 1 292 292 251 292 1 292 1 1 1 292 1 1 1 251 441 446 292
## [253] 1 1 292 451 1 1 292 455 292 251 1 292 292 459 292 251 1 1
## [271] 437 292 1 1 1 463 463 1 1 292 1 292 1 1 1 1 1 1
## [289] 292 1 1 1 292 1 471 471 479 1 292 1 1 1 292 1 292 1
## [307] 251 1 1 292 292 1 1 1 483 1 1 487 1 251 1 292 251 491
## [325] 495 292 1 1 1 292 292 292 251 1 1 1 292 1 1 1 292 292
## [343] 1 1 1 292 292 1 292 292 1 292 251 251 1 1 292 1 292 292
## [361] 251 292 1 292 1 1 1 292 1 1 1 251 441 446 292 1 1 292
## [379] 451 1 1 292 455 292 251 1 292 292 459 292 251 1 1 437 292 1
## [397] 1 1 463 463 1 1 292 1 292 1 1 1 1 1 1 292 1 1
## [415] 1 292 1 471 471 479 1 292 1 1 1 292 1 292 1 251 1 1
## [433] 292 292 1 1 1 483 1 1 487 1 251 1 292 251 491 495 292 1
## [451] 1 1 292 292 292 251 1 1 1 292 1 1 1 292 292 1 1 1
## [469] 292 292 1 292 292 1 292 251 251 1 1 292 1 292 292 251 292 1
## [487] 292 1 1 1 292 1 1 1 251 441 446 292
#plotting
# What's the majority gender that has higher GPA ?
#Scatterplot
ggplot(data=dataset,mapping = aes(x=GPAA,y=Gender))+geom_point()
# Barchart
ggplot(data=dataset)+geom_bar(mapping=aes(x=Gender))
The above figures shows that the majority gender of students is females ;however, when it comes to the GPA of each student. Then both are equivalent in competing for a higher GPA
# Does student's income affect the number of meals that he or she eat out ?
#barchart
ggplot(dataset, aes(x=pay_meal_out, y=income)) +
geom_bar(stat = "identity",width=0.2)+coord_flip()
## Warning: Removed 373 rows containing missing values (position_stack).
The above figure shows the status income of the students along with how frequent they pay meal out. The figure illustrates that the more the students has income, the more they will pay meal out and eat junk food. As they will not be concerned about how many will they pay outside.
#Is being an employed student affect your income ?
#Barchart
ggplot(dataset, aes(x=employment2,y=income)) +
geom_bar(stat = "identity",width=0.50)+coord_flip()
The figure above shows that the students who work 2 and 3 jobs are more exposed to eat out than the students who never work only 1 job.However, students who do not work at all eat out frequently more than any employed student.
#Does drinking coffee affect the student's performance in exercises
#BarChart
ggplot(dataset, aes(x=exercise,y=CoffeAddict)) +
geom_bar(stat = "identity",width=0.50)+coord_flip()
## Warning: Removed 386 rows containing missing values (position_stack).
The above figure shows that students who drink more coffee do more number of exercises which are 3 per week than who do not drink coffee and they do exercise only once per week
#Do vitamins intake affects students' academic performance
#Scatterplot
ggplot(data=dataset,mapping = aes(x=GPAA,y=vitamins, colour=Gender))+geom_point(na.rm=TRUE)
#The relation between the favorite food and the carbon dioxide emissions as kilos
#Scatetrplot
ggplot(data=dataset,mapping = aes(x=Co2KilosS,y=fav_food))+geom_point()
#BarGraph
p<-ggplot(data=dataset, aes(x=Co2KilosS, y=fav_food)) +
geom_bar(stat="identity", fill="steelblue")+
theme_minimal()
p
The previous graph shows the relationship between the students’ favorite food choice and how its related to the carbon dioxide emitted in the environment.Since the majority prefers lamb then they will aid in increasing the pollution of the environment. The Lamb has the highest CO2 while lentil has the lowest carbon dioxide, but it’s barely selected by the students.
#Do students eat out while they're studying ?
# Testing the correlation between the students frequency of eating out AND their studying hours ?
cortest1<-cor.test(dataset$eating_Out,dataset$Studying_hrs, method ="pearson",use="complete.obs")
cortest1$estimate
## cor
## 0.8656337
cortest1$p.value
## [1] 3.956245e-151
The previous reason shows that there is a strong positive correlation between eating out and the studying hour, as eating out affects the students to studying more strongly.
#The summation of calories of all the food that was eaten by the students including chicken, turkey, tortilla, scone and waffles
dataset$caloriesSum<-(dataset$calories_chicken+dataset$tortilla_calories+dataset$calories_scone+dataset$waffle_calories+dataset$turkey_calories)
dataset$caloriesSum
## [1] 3570 3345 3705 3580 3340 4190 3975 3680 2680 2570 3775 3480 2865 4360 3370
## [16] 4010 2370 3750 4870 3035 4920 3050 4135 3975 3895 3755 4360 4570 3785 2525
## [31] 3895 3975 2610 3705 3630 3420 3595 3895 4760 4870 2945 4645 3370 3595 3015
## [46] 3265 2820 3595 2790 3500 3565 4570 3595 4345 3560 3265 4015 3975 4200 4010
## [61] 4200 4130 4920 4760 3230 3050 3480 3975 2730 4310 4570 4310 4415 4470 2370
## [76] 3370 4200 2655 3380 4470 3415 3155 2080 3795 3315 2420 3010 4310 5030 3595
## [91] 4470 3155 3895 4310 3975 3855 2975 3565 4205 3605 NaN 4010 3370 2860 4085
## [106] 4310 2585 3605 2535 3975 3095 3630 3050 3605 3475 4760 3415 3100 3450 4200
## [121] 3785 3335 3725 3895 2390 NA NA NA NA NA NA NA NA NA NA
## [136] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [151] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [166] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [181] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [196] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [211] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [226] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [241] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [256] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [271] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [286] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [301] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [316] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [331] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [346] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [361] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [376] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [391] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [406] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [421] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [436] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [451] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [466] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [481] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
## [496] NA NA NA
dataset$IntcaloriesSum<-as.integer(dataset$caloriesSum)
is.integer(dataset$IntcaloriesSum)
## [1] TRUE
# Since the p-value of sum of calories eaten by each student is greater than 0.05 then it follows a normal distribution
dataset$SumCal<- sqrt(dataset$IntcaloriesSum)
dataset$SumCal<-as.numeric(dataset$SumCal)
shapiro.test(dataset$SumCal)
##
## Shapiro-Wilk normality test
##
## data: dataset$SumCal
## W = 0.98356, p-value = 0.1374
#Histogram sinceas.numeric()s in food eaten by the students is numerical and follows normal distribution
hist(dataset$SumCal ,col="pink")
In the variable sumCal above, We got the square root of the sum of calories eaten by each student to get the data into a normal distribution form as the data is skewed in order to put it in a kendall correlation to know the dependency between the total calories eaten by a student and his total weight.
cortest2<-cor.test(dataset$weightINKG,dataset$SumCal,method ="kendall",use="complete.obs")
cortest2$estimate
## tau
## 0.08818776
The previous correlation shows a strong dependency between the student’s weight and students Sum of calories by the food that they eat
#There is a correlation between the students' studying hours and becoming a vegan
cortest3<-cor.test(dataset$Studying_hrs,dataset$Vegan,method ="pearson",use="complete.obs")
cortest3$estimate
## cor
## 0.05047324
The previous correlation shows that there is a weak relationship between being a vegan student and the hours of studying.
#calling the function calories reduction with the total of the calories that a student eat which are found in
#turkey, tortilla, scone, waffles and chicken
dataset$CaloriesReduction<-CaloriesReduction(dataset$IntcaloriesSum)
dataset$CaloriesReductionInt<-as.integer(dataset$CaloriesReduction)
is.integer(dataset$CaloriesReductionInt)
## [1] TRUE
#The Calories Reduction follows normal distribution since its p-value is greater than 0.05
dataset$caloReduction<- sqrt(CaloriesReduction(dataset$SumCal,dataset$exercise))
dataset$caloReduction
## [1] 55.40758 53.33854 52.00961 45.60702 53.29165 56.48008 58.94913 51.76872
## [9] NaN 45.49725 57.22762 54.58938 36.94591 57.96551 48.68265 59.24525
## [17] 37.01351 57.00877 58.05170 45.11097 66.48308 50.49752 60.29096 49.74937
## [25] NaN 57.05261 62.12890 63.79655 52.77310 39.05125 53.80520 54.54356
## [33] NaN 46.95743 55.94640 54.03702 55.63272 48.93874 61.31884 66.10598
## [41] 49.44694 64.38167 NaN NaN 50.14978 NaN 42.66146 55.63272
## [49] 47.85394 50.00000 55.36244 63.79655 55.63272 NaN 55.31727 52.58327
## [57] 59.28744 58.94913 56.56854 NaN 60.82763 55.94640 66.48308 65.26868
## [65] 52.24940 45.27693 NaN 54.54356 47.22288 57.53260 59.74948 61.72520
## [73] 58.43800 63.00794 37.01351 53.57238 56.56854 40.68169 53.66563 63.00794
## [81] 49.14265 51.52669 39.74921 NaN 53.05657 30.33150 44.83302 61.72520
## [89] 67.30527 55.63272 63.00794 46.42198 48.93874 53.00943 58.94913 57.92236
## [97] 44.44097 55.36244 56.61272 NaN NA 50.09990 53.57238 43.12772
## [105] NaN 57.53260 39.81206 55.72253 45.11097 49.74937 45.77117 51.28353
## [113] 50.49752 51.03920 49.74937 65.26868 49.14265 NaN 49.49747 56.56854
## [121] 52.77310 48.32184 52.20153 58.26663 37.28270 NA NA NA
## [129] NA NA NA NA NA NA NA NA
## [137] NA NA NA NA NA NA NA NA
## [145] NA NA NA NA NA NA NA NA
## [153] NA NA NA NA NA NA NA NA
## [161] NA NA NA NA NA NA NA NA
## [169] NA NA NA NA NA NA NA NA
## [177] NA NA NA NA NA NA NA NA
## [185] NA NA NA NA NA NA NA NA
## [193] NA NA NA NA NA NA NA NA
## [201] NA NA NA NA NA NA NA NA
## [209] NA NA NA NA NA NA NA NA
## [217] NA NA NA NA NA NA NA NA
## [225] NA NA NA NA NA NA NA NA
## [233] NA NA NA NA NA NA NA NA
## [241] NA NA NA NA NA NA NA NA
## [249] NA NA NA NA NA NA NA NA
## [257] NA NA NA NA NA NA NA NA
## [265] NA NA NA NA NA NA NA NA
## [273] NA NA NA NA NA NA NA NA
## [281] NA NA NA NA NA NA NA NA
## [289] NA NA NA NA NA NA NA NA
## [297] NA NA NA NA NA NA NA NA
## [305] NA NA NA NA NA NA NA NA
## [313] NA NA NA NA NA NA NA NA
## [321] NA NA NA NA NA NA NA NA
## [329] NA NA NA NA NA NA NA NA
## [337] NA NA NA NA NA NA NA NA
## [345] NA NA NA NA NA NA NA NA
## [353] NA NA NA NA NA NA NA NA
## [361] NA NA NA NA NA NA NA NA
## [369] NA NA NA NA NA NA NA NA
## [377] NA NA NA NA NA NA NA NA
## [385] NA NA NA NA NA NA NA NA
## [393] NA NA NA NA NA NA NA NA
## [401] NA NA NA NA NA NA NA NA
## [409] NA NA NA NA NA NA NA NA
## [417] NA NA NA NA NA NA NA NA
## [425] NA NA NA NA NA NA NA NA
## [433] NA NA NA NA NA NA NA NA
## [441] NA NA NA NA NA NA NA NA
## [449] NA NA NA NA NA NA NA NA
## [457] NA NA NA NA NA NA NA NA
## [465] NA NA NA NA NA NA NA NA
## [473] NA NA NA NA NA NA NA NA
## [481] NA NA NA NA NA NA NA NA
## [489] NA NA NA NA NA NA NA NA
## [497] NA NA
shapiro.test(dataset$caloReduction)
##
## Shapiro-Wilk normality test
##
## data: dataset$caloReduction
## W = 0.97938, p-value = 0.08342
#Histogram of Calories Reduction since it follows normal distribution
hist(dataset$caloReduction ,col="green")
#There is a negative strong correlation between the students who study for long hours and the calories reduction that is produced by their number of doing exercises
cortest4<-cor.test(dataset$Studying_hrs,dataset$caloReduction, method ="pearson",use="complete.obs")
cortest4$estimate
## cor
## -0.0885432
The previous correlation shows that there is a negative strong correlation between the students who study for long hours and the calories reduction that is produced by their number of doing exercises. Which means that students who study do not move a lot or do exercises and they eat without burning calories.
#Students' coffee intake follows normal distribution because its p value is greater than 0.05
shapiro.test(dataset$CoffeAddict)
##
## Shapiro-Wilk normality test
##
## data: dataset$CoffeAddict
## W = 0.98598, p-value = 0.0866
#Histogram to illustrates the students' coffee intake since its numerical and follows normal distribution
hist(dataset$CoffeAddict ,col="brown")
#Normal Distribution representation of students' coffee intake
ggqqplot(dataset$CoffeAddict,ylab="Students Coffee Intake")
## Warning: Removed 328 rows containing non-finite values (stat_qq).
## Warning: Removed 328 rows containing non-finite values (stat_qq_line).
## Warning: Removed 328 rows containing non-finite values (stat_qq_line).
# Testing the correlation between the students' studying hours and their AND their coffee intake
# There is a strong correlation between the studying hours and the coffee intake that has strong caffeine
cortest5<-cor.test(dataset$Studying_hrs,dataset$CoffeAddict, method ="pearson",use="complete.obs")
cortest5$estimate
## cor
## 0.06729047
#Testing the correlation between the car removal and the students' percentage of following Mediterranean diet
cortest6<-cor.test(dataset3$car_removal,dataset3$meditertanean_diet, method ="pearson",use="complete.obs")
cortest6$estimate
## cor
## 0.309131
cortest6$p.value
## [1] 1.729376e-12
There is a weak positive correlation in the previous relation between students who follow Mediterranean diet and the car removal.As the p value is smaller than 0.05 and students who are likely to eat Mediterranean diet, will reduce the carbon dioxide inside their body. Which makes a relationship between removing cars from the streets ,because these cars pollute the environment.
#Correlation Matrix to drop every categorical value
num_dataset<-dataset2[,sapply(dataset2,is.numeric)]
corrres1<-cor(num_dataset,use="complete.obs",method = "pearson")
corrres1
## Studying_hrs eating_Out CoffeAddict
## Studying_hrs 1.00000000 0.87319518 0.06729047
## eating_Out 0.87319518 1.00000000 0.03673891
## CoffeAddict 0.06729047 0.03673891 1.00000000
#Correlation Matrix for the dataset
corrrelationMatrix<-round(cor(corrres1),1)
corrrelationMatrix
## Studying_hrs eating_Out CoffeAddict
## Studying_hrs 1 1 -1
## eating_Out 1 1 -1
## CoffeAddict -1 -1 1
#Get matrix correlation p-values
pMatrix<-cor_pmat(corrres1)
corrHeatmapplot <- ggcorrplot(
corrrelationMatrix, hc.order = TRUE, type = "lower", outline.col = "white",
p.mat = pMatrix)
corrHeatmapplot
ggplotly(corrHeatmapplot)
## Warning in L$marker$color[idx] <- aes2plotly(data, params, "fill")[idx]: number
## of items to replace is not a multiple of replacement length
The heat map above shows that there is a weak positive correlation with 0.16 between the studying hours and eating out correlation. This means that when the students eat out, their studying hours will increase but not strongly affected, as a slightly change will happen. While there is a weak negative correlation between students studying hours and their drinking amount of coffee, in which the studying hours increase when the coffee percentage is less. Not a strong effect but there will be an effect on the student. which concludes that caffeine is an illusion for giving certain amount of power to the brain cells. However, students seem to need caffeine to return to their normal state of alertness and to avoid the side effects of caffeine withdrawal such as headaches.and those who normally drank few caffeinated beverages didn’t notice much of a difference in their level of alertness when given a placebo versus caffeine. Eating out and coffee addict has a weak negative correlation , in which the students who eat out has nothing interfered with their choice and most probably they forget to drink coffee and food for them in enough and makes them satisfied.
#step 1 :checking normality
shapiro.test(dataset2$Studying_hrs)
##
## Shapiro-Wilk normality test
##
## data: dataset2$Studying_hrs
## W = 0.98705, p-value = 0.0002095
shapiro.test(dataset2$eating_Out)
##
## Shapiro-Wilk normality test
##
## data: dataset2$eating_Out
## W = 0.95185, p-value = 1.159e-11
shapiro.test(dataset2$CoffeAddict)
##
## Shapiro-Wilk normality test
##
## data: dataset2$CoffeAddict
## W = 0.98598, p-value = 0.0866
#step 2: check Linearity
LinearCheck<-scatter.smooth(x=dataset2$Studying_hrs,y=dataset2$eating_Out,main="Studying_hrs ~ eating_Out")
reg<-lm(formula =Studying_hrs ~ eating_Out, data = dataset2)
summary(reg)
##
## Call:
## lm(formula = Studying_hrs ~ eating_Out, data = dataset2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.02479 -0.48526 0.04078 0.45898 2.37805
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.20427 0.08884 2.299 0.0219 *
## eating_Out 0.71383 0.01854 38.505 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7181 on 496 degrees of freedom
## Multiple R-squared: 0.7493, Adjusted R-squared: 0.7488
## F-statistic: 1483 on 1 and 496 DF, p-value: < 2.2e-16
#remove outliers
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
summary(dataset2$Studying_hrs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.266 2.266 3.473 3.393 4.503 6.863
firstquart<-2.266
thirdquart<-4.503
val<-thirdquart - firstquart
val<-val*1.5
maxval<-thirdquart + val
minval<-firstquart - val
library(assertive)
mean(dataset2$Studying_hrs)
## [1] 3.392859
replace(dataset2$Studying_hrs,dataset2$Studying_hrs<minval,NA)
## [1] 2.3144890 3.4334898 4.5993734 2.7911138 5.5963983 2.4585559 3.1929918
## [8] 1.9071368 2.9424499 3.7379416 3.1754061 2.0090465 5.9518141 5.9605473
## [15] 1.4457989 2.8985831 1.2311675 2.3129881 2.6661160 2.5847290 5.7474441
## [22] 2.5465246 1.2007855 3.0782934 4.3177609 5.3814787 3.5652243 0.9534130
## [29] 2.1691613 2.0607943 6.2991013 1.5903559 2.2509294 5.9142477 2.1918337
## [36] 5.7678144 0.9728829 5.0105774 2.2396650 1.9275788 3.3580716 2.4000873
## [43] 3.4079800 2.5761763 2.4730794 3.7526595 4.0876312 3.5432037 5.3483529
## [50] 3.0563767 1.5584226 3.2251328 5.0342310 3.8574243 3.6190555 4.0045377
## [57] 4.8020918 4.6588904 5.2317030 2.4806065 5.4981472 4.5506370 3.5700136
## [64] 4.7196653 4.5031082 5.0460818 0.6697159 1.6060724 4.8266027 2.2082405
## [71] 4.0564931 3.5679052 1.3084873 4.1596093 4.6339151 5.0687479 3.0407973
## [78] 3.8042989 5.0340038 3.7034379 2.1889381 5.5380475 3.5838752 3.0968856
## [85] 2.2009822 5.1515983 5.9509863 2.9681871 2.3995613 0.8594991 1.7759326
## [92] 4.6612612 0.7272212 0.7712866 3.3487882 3.9662154 2.8904474 3.7732607
## [99] 6.3596000 0.2687221 4.3748323 2.1558433 1.8935569 4.9029916 4.8335064
## [106] 3.1722995 5.0299517 4.2610130 1.6723906 1.4970241 1.2654889 2.6674654
## [113] 1.9993255 5.2318633 5.2114013 3.6616565 1.4150347 4.9330441 4.1307783
## [120] 2.2822669 3.9011703 4.6919989 3.5778007 5.5625455 2.3932281 3.5647237
## [127] 2.2537215 4.1216477 4.1691008 3.8238987 0.4583776 2.5769400 2.9475315
## [134] 3.7399958 3.5714465 4.8081504 4.0176112 1.8398020 3.4685738 4.7587855
## [141] 2.3916775 0.9929174 3.1693802 2.0890424 1.8436758 1.6166074 5.9493475
## [148] 4.9402278 2.8412387 2.9443913 3.0269182 5.0978025 3.0368199 4.6828170
## [155] 4.0008192 4.5708011 2.0427393 1.7486511 6.0640130 5.1324015 3.1133421
## [162] 4.8218103 4.1795210 1.6312611 3.8221796 1.8575419 3.7510893 3.1586186
## [169] 4.9271326 4.6001148 2.4083799 4.4867037 2.7277157 3.0207244 3.7491807
## [176] 2.3115542 0.9876032 1.4611444 4.5768565 4.7675956 0.4381716 2.3512025
## [183] 3.4531027 5.3813985 4.8200912 4.6587427 5.3800702 3.3159895 2.7997475
## [190] 4.2067549 4.4026632 2.7691181 2.7842445 0.6880906 3.4764991 5.8361967
## [197] 2.0039261 0.9713325 2.8576144 1.8521177 3.5151792 2.1005525 6.0864783
## [204] 4.0838212 1.5247823 2.5795165 1.6192261 5.5066215 1.0959993 0.9685273
## [211] 4.8777255 1.7596987 5.0322110 5.7138023 4.7958429 4.6602900 2.7403954
## [218] 4.2505681 3.9410193 4.5034454 4.6332287 4.0308649 6.8633880 5.0794759
## [225] 1.6252684 6.6182798 4.6569986 6.0049875 2.4106356 4.2612200 1.0656238
## [232] 2.2957001 1.9195111 3.5813810 0.6289421 3.3441084 6.1604341 2.8612744
## [239] 4.2094706 1.2262981 4.7933252 3.3137965 2.1526984 2.9236839 3.4520672
## [246] 4.2583115 3.9610328 3.4277232 4.7209873 1.5719498 6.1869456 3.5527370
## [253] 1.2457859 3.4269117 1.8771470 1.8178891 5.2399095 1.3840441 3.8379778
## [260] 2.3216977 3.3115782 3.0573878 4.7370460 4.5909705 0.6542421 3.9811277
## [267] 2.3362760 4.5406361 2.1927449 1.7881763 2.7194322 4.2126973 4.4772714
## [274] 2.4688600 3.4517725 0.6869208 2.2467457 1.6276951 2.4532091 4.1099447
## [281] 2.5725982 4.8104241 4.8274163 2.4657611 3.7573790 3.6913482 1.9818099
## [288] 1.4102296 3.7543014 4.2452156 1.4378767 4.1598871 3.5148918 2.7144980
## [295] 1.3573731 5.6384604 2.4214647 1.5112051 5.5228917 4.3966223 3.9884528
## [302] 3.3176068 2.7796826 0.8465055 2.4579217 3.5096047 2.6469045 2.9779167
## [309] 1.4244505 1.7903423 1.6446366 0.7316363 2.9017886 4.3171332 2.0973691
## [316] 4.3915930 5.3139569 6.2813702 5.6079666 2.9468704 3.8727888 2.8428684
## [323] 1.4606163 3.7528248 3.1266032 2.8211926 2.7349601 2.1975921 4.1555409
## [330] 4.0782088 4.4569636 4.9392590 3.7305700 2.5750549 2.1763221 6.2369553
## [337] 0.8987328 3.6294244 5.9233461 0.5461902 3.0314971 2.8478168 4.5169606
## [344] 4.5916970 3.1577651 4.2879997 3.6188298 3.2007979 3.9997030 1.6622532
## [351] 2.3915500 3.0676095 2.0175136 3.6408840 0.2660437 1.2954273 1.8533476
## [358] 5.3672361 2.4662923 1.7235936 4.3072884 3.1563674 1.6904581 5.0855230
## [365] 2.4816239 1.3533173 5.2752942 3.6702915 3.6963904 2.6798873 2.3635647
## [372] 1.4385961 5.3624483 2.3253092 1.5295609 4.0357270 3.5503372 3.5546003
## [379] 4.1997285 3.1354752 1.1452958 3.5398541 3.8222040 3.8355776 5.6837506
## [386] 2.5174009 4.3246604 2.9586968 1.6809971 4.2535013 2.2603957 3.6154711
## [393] 1.5022116 3.7764846 3.2010424 4.0583116 4.1052245 3.7220976 3.8222703
## [400] 3.7066610 4.9096885 2.1557336 5.7437361 4.3375715 2.5824166 4.2843056
## [407] 2.9621682 3.9904159 5.8901487 3.6885395 3.2178474 2.2204703 5.9102849
## [414] 4.8530325 3.8029736 3.0921646 3.2333137 5.2654790 4.8115334 5.3680412
## [421] 1.7987183 4.7600143 3.4158065 5.0401746 1.9656359 1.8719579 5.3235074
## [428] 4.5011583 2.4350949 4.5532165 4.3617093 1.4787872 2.7685231 3.9606364
## [435] 5.9157814 3.9801953 4.7082030 1.4166611 4.3284171 6.1962955 1.9459611
## [442] 0.6984600 5.1354553 1.5603554 4.2349912 0.6889092 0.6858489 1.7917536
## [449] 3.2274722 5.1593312 3.8029707 4.2160576 4.9324100 2.2334406 4.3782594
## [456] 3.4839257 2.0302970 3.5963983 3.2611821 3.4811378 3.3934392 4.2296633
## [463] 4.3213643 4.4004551 3.3575974 5.3357180 5.5883893 2.9942043 2.4133818
## [470] 4.9853666 4.9819811 6.3842745 3.2674754 1.3127590 4.0395480 4.4259951
## [477] 3.3427494 3.4923102 3.7512255 5.3865593 5.9634221 4.9852549 2.7981607
## [484] 2.9673233 1.2287732 3.9617296 4.6491437 4.7541684 2.9619567 4.6334411
## [491] 1.2941366 0.5483652 2.1151365 4.5687046 2.5350021 4.3974513 2.0706638
## [498] 3.7101930
replace(dataset2$Studying_hrs,dataset2$Studying_hrs>maxval,NA)
## [1] 2.3144890 3.4334898 4.5993734 2.7911138 5.5963983 2.4585559 3.1929918
## [8] 1.9071368 2.9424499 3.7379416 3.1754061 2.0090465 5.9518141 5.9605473
## [15] 1.4457989 2.8985831 1.2311675 2.3129881 2.6661160 2.5847290 5.7474441
## [22] 2.5465246 1.2007855 3.0782934 4.3177609 5.3814787 3.5652243 0.9534130
## [29] 2.1691613 2.0607943 6.2991013 1.5903559 2.2509294 5.9142477 2.1918337
## [36] 5.7678144 0.9728829 5.0105774 2.2396650 1.9275788 3.3580716 2.4000873
## [43] 3.4079800 2.5761763 2.4730794 3.7526595 4.0876312 3.5432037 5.3483529
## [50] 3.0563767 1.5584226 3.2251328 5.0342310 3.8574243 3.6190555 4.0045377
## [57] 4.8020918 4.6588904 5.2317030 2.4806065 5.4981472 4.5506370 3.5700136
## [64] 4.7196653 4.5031082 5.0460818 0.6697159 1.6060724 4.8266027 2.2082405
## [71] 4.0564931 3.5679052 1.3084873 4.1596093 4.6339151 5.0687479 3.0407973
## [78] 3.8042989 5.0340038 3.7034379 2.1889381 5.5380475 3.5838752 3.0968856
## [85] 2.2009822 5.1515983 5.9509863 2.9681871 2.3995613 0.8594991 1.7759326
## [92] 4.6612612 0.7272212 0.7712866 3.3487882 3.9662154 2.8904474 3.7732607
## [99] 6.3596000 0.2687221 4.3748323 2.1558433 1.8935569 4.9029916 4.8335064
## [106] 3.1722995 5.0299517 4.2610130 1.6723906 1.4970241 1.2654889 2.6674654
## [113] 1.9993255 5.2318633 5.2114013 3.6616565 1.4150347 4.9330441 4.1307783
## [120] 2.2822669 3.9011703 4.6919989 3.5778007 5.5625455 2.3932281 3.5647237
## [127] 2.2537215 4.1216477 4.1691008 3.8238987 0.4583776 2.5769400 2.9475315
## [134] 3.7399958 3.5714465 4.8081504 4.0176112 1.8398020 3.4685738 4.7587855
## [141] 2.3916775 0.9929174 3.1693802 2.0890424 1.8436758 1.6166074 5.9493475
## [148] 4.9402278 2.8412387 2.9443913 3.0269182 5.0978025 3.0368199 4.6828170
## [155] 4.0008192 4.5708011 2.0427393 1.7486511 6.0640130 5.1324015 3.1133421
## [162] 4.8218103 4.1795210 1.6312611 3.8221796 1.8575419 3.7510893 3.1586186
## [169] 4.9271326 4.6001148 2.4083799 4.4867037 2.7277157 3.0207244 3.7491807
## [176] 2.3115542 0.9876032 1.4611444 4.5768565 4.7675956 0.4381716 2.3512025
## [183] 3.4531027 5.3813985 4.8200912 4.6587427 5.3800702 3.3159895 2.7997475
## [190] 4.2067549 4.4026632 2.7691181 2.7842445 0.6880906 3.4764991 5.8361967
## [197] 2.0039261 0.9713325 2.8576144 1.8521177 3.5151792 2.1005525 6.0864783
## [204] 4.0838212 1.5247823 2.5795165 1.6192261 5.5066215 1.0959993 0.9685273
## [211] 4.8777255 1.7596987 5.0322110 5.7138023 4.7958429 4.6602900 2.7403954
## [218] 4.2505681 3.9410193 4.5034454 4.6332287 4.0308649 6.8633880 5.0794759
## [225] 1.6252684 6.6182798 4.6569986 6.0049875 2.4106356 4.2612200 1.0656238
## [232] 2.2957001 1.9195111 3.5813810 0.6289421 3.3441084 6.1604341 2.8612744
## [239] 4.2094706 1.2262981 4.7933252 3.3137965 2.1526984 2.9236839 3.4520672
## [246] 4.2583115 3.9610328 3.4277232 4.7209873 1.5719498 6.1869456 3.5527370
## [253] 1.2457859 3.4269117 1.8771470 1.8178891 5.2399095 1.3840441 3.8379778
## [260] 2.3216977 3.3115782 3.0573878 4.7370460 4.5909705 0.6542421 3.9811277
## [267] 2.3362760 4.5406361 2.1927449 1.7881763 2.7194322 4.2126973 4.4772714
## [274] 2.4688600 3.4517725 0.6869208 2.2467457 1.6276951 2.4532091 4.1099447
## [281] 2.5725982 4.8104241 4.8274163 2.4657611 3.7573790 3.6913482 1.9818099
## [288] 1.4102296 3.7543014 4.2452156 1.4378767 4.1598871 3.5148918 2.7144980
## [295] 1.3573731 5.6384604 2.4214647 1.5112051 5.5228917 4.3966223 3.9884528
## [302] 3.3176068 2.7796826 0.8465055 2.4579217 3.5096047 2.6469045 2.9779167
## [309] 1.4244505 1.7903423 1.6446366 0.7316363 2.9017886 4.3171332 2.0973691
## [316] 4.3915930 5.3139569 6.2813702 5.6079666 2.9468704 3.8727888 2.8428684
## [323] 1.4606163 3.7528248 3.1266032 2.8211926 2.7349601 2.1975921 4.1555409
## [330] 4.0782088 4.4569636 4.9392590 3.7305700 2.5750549 2.1763221 6.2369553
## [337] 0.8987328 3.6294244 5.9233461 0.5461902 3.0314971 2.8478168 4.5169606
## [344] 4.5916970 3.1577651 4.2879997 3.6188298 3.2007979 3.9997030 1.6622532
## [351] 2.3915500 3.0676095 2.0175136 3.6408840 0.2660437 1.2954273 1.8533476
## [358] 5.3672361 2.4662923 1.7235936 4.3072884 3.1563674 1.6904581 5.0855230
## [365] 2.4816239 1.3533173 5.2752942 3.6702915 3.6963904 2.6798873 2.3635647
## [372] 1.4385961 5.3624483 2.3253092 1.5295609 4.0357270 3.5503372 3.5546003
## [379] 4.1997285 3.1354752 1.1452958 3.5398541 3.8222040 3.8355776 5.6837506
## [386] 2.5174009 4.3246604 2.9586968 1.6809971 4.2535013 2.2603957 3.6154711
## [393] 1.5022116 3.7764846 3.2010424 4.0583116 4.1052245 3.7220976 3.8222703
## [400] 3.7066610 4.9096885 2.1557336 5.7437361 4.3375715 2.5824166 4.2843056
## [407] 2.9621682 3.9904159 5.8901487 3.6885395 3.2178474 2.2204703 5.9102849
## [414] 4.8530325 3.8029736 3.0921646 3.2333137 5.2654790 4.8115334 5.3680412
## [421] 1.7987183 4.7600143 3.4158065 5.0401746 1.9656359 1.8719579 5.3235074
## [428] 4.5011583 2.4350949 4.5532165 4.3617093 1.4787872 2.7685231 3.9606364
## [435] 5.9157814 3.9801953 4.7082030 1.4166611 4.3284171 6.1962955 1.9459611
## [442] 0.6984600 5.1354553 1.5603554 4.2349912 0.6889092 0.6858489 1.7917536
## [449] 3.2274722 5.1593312 3.8029707 4.2160576 4.9324100 2.2334406 4.3782594
## [456] 3.4839257 2.0302970 3.5963983 3.2611821 3.4811378 3.3934392 4.2296633
## [463] 4.3213643 4.4004551 3.3575974 5.3357180 5.5883893 2.9942043 2.4133818
## [470] 4.9853666 4.9819811 6.3842745 3.2674754 1.3127590 4.0395480 4.4259951
## [477] 3.3427494 3.4923102 3.7512255 5.3865593 5.9634221 4.9852549 2.7981607
## [484] 2.9673233 1.2287732 3.9617296 4.6491437 4.7541684 2.9619567 4.6334411
## [491] 1.2941366 0.5483652 2.1151365 4.5687046 2.5350021 4.3974513 2.0706638
## [498] 3.7101930
summary(dataset2$eating_Out)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.506 3.006 4.424 4.467 5.992 7.482
firstquart2<-3.006
thirdquart2<-5.992
val2<-thirdquart2 - firstquart2
val2<-val2*1.5
maxval2<- thirdquart2 + val2
maxval2
## [1] 10.471
minval2<-firstquart2 - val2
minval2
## [1] -1.473
replace(dataset2$eating_Out,dataset2$eating_Out>minval2,mean(dataset2$eating_Out))
## [1] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [9] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [17] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [25] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [33] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [41] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [49] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [57] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [65] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [73] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [81] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [89] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [97] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [105] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [113] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [121] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [129] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [137] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [145] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [153] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [161] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [169] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [177] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [185] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [193] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [201] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [209] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [217] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [225] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [233] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [241] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [249] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [257] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [265] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [273] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [281] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [289] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [297] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [305] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [313] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [321] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [329] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [337] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [345] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [353] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [361] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [369] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [377] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [385] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [393] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [401] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [409] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [417] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [425] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [433] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [441] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [449] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [457] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [465] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [473] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [481] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [489] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [497] 4.466902 4.466902
replace(dataset2$eating_Out,dataset2$eating_Out<maxval2,mean(dataset2$eating_Out))
## [1] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [9] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [17] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [25] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [33] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [41] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [49] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [57] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [65] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [73] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [81] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [89] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [97] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [105] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [113] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [121] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [129] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [137] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [145] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [153] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [161] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [169] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [177] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [185] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [193] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [201] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [209] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [217] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [225] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [233] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [241] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [249] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [257] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [265] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [273] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [281] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [289] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [297] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [305] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [313] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [321] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [329] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [337] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [345] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [353] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [361] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [369] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [377] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [385] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [393] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [401] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [409] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [417] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [425] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [433] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [441] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [449] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [457] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [465] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [473] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [481] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [489] 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902 4.466902
## [497] 4.466902 4.466902
ggplot(dataset2,aes(x=Studying_hrs,y=eating_Out))+geom_point(na.rm = TRUE)+geom_smooth(method = "lm",col="blue")+stat_regline_equation(label.x=3,label.y=7)+theme_bw()+labs(title = "studying hours/eating out",x="studying hours",y="eating out")
## `geom_smooth()` using formula 'y ~ x'
The previous is the linear regression to test the dependency between the correlated student studying hours and their rate of eating out. There was a correlation between the variables that was applied previously.The linearity was checked through the The outliers were removed from the data by using the equation IQR= Q3-Q1 , then multiplied the IQR by 1.5. Then added the value to Q3 with IQR and subtract IQR from Q1 to get the outliers. Afterwards, the range was between 12.7105 and -3.7125. Any value outside was removed. There is dependency between students’ studying hours and eating out, in which eating out is depending on the number of studying hours that each students takes and it increases along it.
dataset3$car_removal<-as.numeric(dataset3$car_removal)
dataset3$meditertanean_diet<-as.numeric(dataset3$car_removal)
#Testing the correlation between the car removal and the Mediterranean diet
cortest6<-cor.test(dataset3$car_removal,dataset3$meditertanean_diet, method ="pearson",use="complete.obs")
cortest6$estimate
## cor
## 1
cortest6$p.value
## [1] 0
The previous correlation shows that there is strong positive relationship between car removal and students following the Mediterranean diet. As students change to Mediterranean diet, the more car removal in the streets will take place.
reg2<-lm(formula = car_removal ~ meditertanean_diet ,dataset3)
dataset3<-expand.grid(meditertanean_diet=seq(min(dataset3$meditertanean_diet),max(dataset3$meditertanean_diet),length.out=30),car_removal=c(min(dataset3$car_removal),mean(dataset3$car_removal),max(dataset3$car_removal)))
temp<-predict(reg2,newdata = dataset3)
dataset3$predicted<-temp
dataset3$car_removal<-as.factor(round(dataset3$car_removal,2))
ggplot(dataset3,mapping = aes(x=meditertanean_diet,y=car_removal))+geom_point()+geom_line(dataset3,mapping = aes(x=meditertanean_diet,y=predicted,color=car_removal),size=1.225)
The previous linear regression shows the dependency between the car removal and the Mediterranean diet. When students get biased to Mediterranean diet , the car removals in the streets will increase.In which these cars emit co2 that pollute the environment.Therefore eating seafood will help the environment.
The data gathered describes the college students’ diet habits and its effect on their academic and sportive life. In addition to the effect of their choices on the outer environment that affects other people in the society. Starting by the supplements or vitamins. It was shown that beginner students who do exercise only once a week depend on taking vitamins, as well as the expert students who do 3 exercises per week. In fact exercises appears to decrease nutrient status of the body; therefore, vitamins increase turnover, metabolism or loss of nutrients; through biochemical adaptations as a result of training that increases nutrient needs, by increase in mitochondrial enzymes, which is the cell house in the human body that uses most of the energy released from the breakdown of nutrients to synthesize ATP. Along with the myth that coffee intake has a role in keeping the students alerted and focused to keep studying for longer hours. Coffee was proofed to be an illusion as the majority of students do not drink coffee and their studying hours are greater, that could reach up to 6 hours, than those who drink coffee. As an interesting fact researchers say that coffee has no benefits gain; however, it increases the risk of anxiety and raises blood pressure. And once a person has been drinking caffeine long enough, their body becomes dependent, so they experience withdrawal symptoms in the absence of caffeine. This is why, for some, drinking a cup of coffee provides an illusion of increased alertness known as placebo effect. When, in reality, it is just normalizing their energy levels, so they go from below minimum functionality to the normal capacity of someone who doesn’t drink coffee. In response, it was found that students who drink more coffee are doing more exercises as they think that coffee is the source of their energy.
Sport and physical activity positively impacts students’ academic performance to get higher GPAs. as it encourages the enhancement of brain function and cognition through increasing blood flow to the brain; increasing levels of norepinephrine and endorphins; and increasing growth factors that help create new nerve cells and support synaptic plasticity. However, playing more than one sport may distract students to focus on their academic performance to reach a 4 GPA. Concluding that it takes time more than usual in their day schedule, well they will still get high GPA, but not reaching the highest compared to playing 1 sport. Using EDA ,it was found that the female students are more in number in the Mercyhurst University, but in the academic competition race both genders gets equivalently the same high GPAs. Eating junk food is a habit especially in the youth generation who are at the age of college, where they don’t have time to meal prep. We tried to categorize their income status along with paying for meals out. It was shown that the students who have higher income rate will pay for junk food more , as paying for ready food will help them to eat without the headache of getting to cook. However, students who have a poor income will not be able to afford paying out every time. They still pay and get junk food, but occasionally. But the income has an impact from the beginning on students’ life habits. As being an employed student will raise your income in order to pay for meal out. People think that when students go out and eat, that they will be distracted as going out consumes time and this will affect the students studying hours. But it was proven extremely wrong, as students studying hour’s increases when they eat out. Considering that students have to be cautious while eating, as their body weight depends on their daily caloric intake. Vegan students have the same studying hours as students who eat meat and chicken. As studying hours quantity don’t define how do students eat .However, it was known that since plant-based foods can also be low in calories, a vegan diet can lead to fatigue if you don’t eat enough to keep your mental and physical energy up. Studying more don’t reduce calories which indicates that students during their studying hours eat snacks and sit without making any movement, which will not burn calories for them. Student who are likely willing to eat Mediterranean diet, which is a diet that includes healthy plant foods and seafood twice a week, are playing a huge role without noticing in the environment . As Mediterranean diet are associated with a lower environmental impact as, among other diets, they reduce greenhouse gas emissions and the use of energy, land and water. The analysis was shown that car removal increases when the students eat Mediterranean diet. As the effect of removing cars from the streets is equivalent to eating Mediterranean diet. In conclusion students affect themselves and other without noticing and several food choices can lead to greater food security and environmental sustainability for future generations; therefore, it’s a huge responsibility to choose what to eat.